@univerjs/sheets-hyper-link-ui 0.5.2 → 0.5.3

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
@@ -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 ft;function on(){if(ft)return Se;ft=1;var e=y,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function o(l,u,d){var p,h={},v=null,g=null;d!==void 0&&(v=""+d),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(g=u.ref);for(p in u)r.call(u,p)&&!c.hasOwnProperty(p)&&(h[p]=u[p]);if(l&&l.defaultProps)for(p in u=l.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:n,type:l,key:v,ref:g,props:h,_owner:i.current}}return Se.Fragment=t,Se.jsx=o,Se.jsxs=o,Se}var yt;function cn(){return yt||(yt=1,Ke.exports=on()),Ke.exports}var m=cn();class Je extends s.Disposable{constructor(){super(...arguments);Z(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==S.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(i=>i.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:r}=this;r.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const an="univer-cell-link-edit",ln="univer-cell-link-edit-buttons",Ct={cellLinkEdit:an,cellLinkEditButtons:ln},Te=()=>{var rt;const[e,n]=y.useState(""),[t,r]=y.useState(!1),[i,c]=y.useState(""),[o,l]=y.useState(!0),[u,d]=y.useState(S.SheetHyperLinkType.URL),[p,h]=y.useState(""),v=s.useDependency(s.LocaleService),g=s.useDependency(X.IDefinedNamesService),C=s.useDependency(f.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),T=s.useDependency(exports.SheetsHyperLinkPopupService),a=b.useObservable(T.currentEditing$),k=s.useDependency(S.SheetsHyperLinkParserService),x=s.useDependency(exports.SheetsHyperLinkResolverService),N=s.useDependency(s.ICommandService),D=s.useDependency(Je),V=y.useMemo(()=>D.getOptions(),[D]),A=s.useDependency(b.IZenZoneService),q=s.useDependency(Ce.IRenderManagerService),pe=s.useDependency(f.IMarkSelectionService),Ee=s.useDependency(fe.DocSelectionManagerService),re=s.useDependency(s.IContextService),de=s.useDependency(s.ThemeService),he=s.useDependency(fe.DocSelectionManagerService),ge=y.useRef({}),ie=y.useMemo(()=>{if(!D.isBuiltInLinkType(u))return D.getCustomHyperLink(u)},[D,u]),[F,At]=y.useState(!1),[ve,Ae]=y.useState(!1),B=y.useRef(!1),W=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),$t=(W==null?void 0:W.getActiveSheet().getSheetId())||"",Q=y.useCallback(_=>{c(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[c]);y.useEffect(()=>{var _,O,P,w,M,K,it,st,ot,ct,at,lt,ut,pt,dt,ht,gt;if((a==null?void 0:a.row)!==void 0&&a.col!==void 0){const{customRange:se,row:Ze,col:We}=a;let{label:J}=a;typeof J=="number"&&(J=`${J}`);let Y;if(se)Y={id:(_=se==null?void 0:se.rangeId)!=null?_:"",display:J!=null?J:"",payload:(P=(O=se==null?void 0:se.properties)==null?void 0:O.url)!=null?P:"",row:Ze,column:We};else if(a.type===I.VIEWING){const U=L.getUnit(a.unitId),te=U==null?void 0:U.getSheetBySheetId(a.subUnitId),j=te==null?void 0:te.getCellRaw(a.row,a.col),le=(K=(M=(w=j==null?void 0:j.p)==null?void 0:w.body)==null?void 0:M.customRanges)==null?void 0:K.find(_t=>{var St;return _t.rangeType===s.CustomRangeType.HYPERLINK&&((St=_t.properties)==null?void 0:St.url)}),_e=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((st=(it=j.p)==null?void 0:it.body)==null?void 0:st.dataStream)||s.Tools.isDefine(_e))&&l(!1),Y={id:"",display:"",payload:(ct=(ot=le==null?void 0:le.properties)==null?void 0:ot.url)!=null?ct:"",row:Ze,column:We}}else{const U=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),te=Ee.getActiveTextRange(),j=U==null?void 0:U.getBody(),le=te&&j?te:null,_e=le&&((lt=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(le,(at=j==null?void 0:j.customRanges)!=null?at:[]))==null?void 0:lt[0]);l(!1),Y={id:"",display:J!=null?J:"",payload:(pt=(ut=_e==null?void 0:_e.properties)==null?void 0:ut.url)!=null?pt:"",row:Ze,column:We}}n(Y.id);const vt=D.findCustomHyperLink(Y);if(vt){const U=vt.convert(Y);d(U.type),h(U.payload),Q(U.display);return}Q(Y.display);const ee=k.parseHyperLink(Y.payload);switch(d(ee.type===S.SheetHyperLinkType.INVALID?S.SheetHyperLinkType.RANGE:ee.type),ee.type){case S.SheetHyperLinkType.URL:{h(ee.url),ee.url===Y.display&&(B.current=!0);break}case S.SheetHyperLinkType.RANGE:{const U=ee.searchObj,te=U.gid&&(gt=(ht=(dt=L.getUnit(a.unitId))==null?void 0:dt.getSheetBySheetId(U.gid))==null?void 0:ht.getName())!=null?gt:"",j=X.serializeRangeWithSheet(te,X.deserializeRangeWithSheet(U.range).range);h(j),j===Y.display&&(B.current=!0);break}case S.SheetHyperLinkType.SHEET:{const U=ee.searchObj;h(U.gid);break}case S.SheetHyperLinkType.DEFINE_NAME:{const U=ee.searchObj;h(U.rangeid);break}default:h("");break}}},[a,x,D,Ee,L]),y.useEffect(()=>{let _=null;if(a&&!a.customRangeId&&a.type===I.VIEWING&&s.Tools.isDefine(a.row)&&s.Tools.isDefine(a.col)){const O=L.getUnit(a.unitId,s.UniverInstanceType.UNIVER_SHEET),P=O==null?void 0:O.getSheetBySheetId(a.subUnitId),w=P==null?void 0:P.getMergedCell(a.row,a.col),M=new s.ColorKit(de.getCurrentTheme().hyacinth500).toRgb();_=pe.addShape({range:w!=null?w:{startColumn:a.col,endColumn:a.col,startRow:a.row,endRow:a.row},style:{fill:`rgb(${M.r}, ${M.g}, ${M.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&pe.removeShape(_)}},[a,pe,de,L]),y.useEffect(()=>{Ae(u===S.SheetHyperLinkType.RANGE)},[u]),y.useEffect(()=>{const _=(a==null?void 0:a.type)===I.ZEN_EDITOR?q.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):q.getRenderById(C.getCurrentEditorId()),O=new s.DisposableCollection;if(_){const P=_.with(ne.DocSelectionRenderService);P.setReserveRangesStatus(!0),O.add(()=>{P.setReserveRangesStatus(!1)})}return()=>{C.disableForceKeepVisible(),O.dispose()}},[a==null?void 0:a.type,C,q]),y.useEffect(()=>(T.setIsKeepVisible(ve),()=>{T.setIsKeepVisible(!1)}),[ve,T]),y.useEffect(()=>()=>{A.temporaryHidden&&(A.show(),re.setContextValue(s.FOCUSING_SHEET,!1))},[re,A]),y.useEffect(()=>{if(ve)return C.enableForceKeepVisible(),()=>{C.disableForceKeepVisible()}},[ve,C]);const Vt=[{label:v.t("hyperLink.form.link"),value:S.SheetHyperLinkType.URL},{label:v.t("hyperLink.form.range"),value:S.SheetHyperLinkType.RANGE},{label:v.t("hyperLink.form.worksheet"),value:S.SheetHyperLinkType.SHEET},{label:v.t("hyperLink.form.definedName"),value:S.SheetHyperLinkType.DEFINE_NAME},...V];if(!W)return;const Ft=W.getHiddenWorksheets(),$e=W.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Ft.indexOf(_.value)===-1),Ve=Object.values((rt=g.getDefinedNameMap(W.getUnitId()))!=null?rt:{}).map(_=>({label:_.name,value:_.id})),nt=(_,O)=>{if(_===S.SheetHyperLinkType.URL)return Jt(O);if(_===S.SheetHyperLinkType.RANGE){const P=X.deserializeRangeWithSheet(O),w=W.getSheetBySheetName(P.sheetName);if(w)return`#gid=${w.getSheetId()}&range=${X.serializeRange(P.range)}`}return`#${_}=${O}`},Zt=b.useEvent(_=>{var M;const P=_.split(",").map(X.deserializeRangeWithSheet)[0];if(!P||!s.isValidRange(P.range))return;P.sheetName||(P.sheetName=((M=W.getActiveSheet())==null?void 0:M.getName())||"");const w=X.serializeRangeToRefString(P);h(w),w&&(B.current||!i)&&(Q(w),B.current=!0)}),Fe=async()=>{if(o&&!i||!p||u===S.SheetHyperLinkType.URL&&!Pe(p)){At(!0);return}if(a)if(e){const _=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.UpdateRichHyperLinkCommand.id:S.UpdateHyperLinkCommand.id;await N.executeCommand(_,{id:e,unitId:a.unitId,subUnitId:a.subUnitId,payload:{display:o?i:"",payload:nt(u,p)},row:a.row,column:a.col,documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}else{const _=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.AddRichHyperLinkCommand.id:S.AddHyperLinkCommand.id;await N.executeCommand(_,{unitId:a.unitId,subUnitId:a.subUnitId,link:{id:s.generateRandomId(),row:a.row,column:a.col,payload:nt(u,p),display:o?i:""},documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}if((a==null?void 0:a.type)===I.VIEWING){await N.executeCommand(E.SetWorksheetActiveOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId});const _=1;await N.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(a.row-_,0),endRow:a.row+_,startColumn:Math.max(a.col-_,0),endColumn:a.col+_}})}N.executeCommand(ye.id)},Wt=_=>{var P;if(u!==S.SheetHyperLinkType.RANGE)return;const O=(P=ge.current)==null?void 0:P.handleOutClick;O&&O(_,()=>Ae(!1))};return a?m.jsxs("div",{className:Ct.cellLinkEdit,style:{display:t?"none":"block"},onClick:Wt,children:[o?m.jsx(H.FormLayout,{label:v.t("hyperLink.form.label"),error:F&&!i?v.t("hyperLink.form.inputError"):"",children:m.jsx(H.Input,{value:i,onChange:_=>{Q(_),B.current=!1},placeholder:v.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===b.KeyCode.ENTER&&Fe()}})}):null,m.jsx(H.FormLayout,{label:v.t("hyperLink.form.type"),children:m.jsx(H.Select,{options:Vt,value:u,onChange:_=>{d(_),h("")}})}),u===S.SheetHyperLinkType.URL&&m.jsx(H.FormLayout,{error:F?p?Pe(p)?"":v.t("hyperLink.form.linkError"):v.t("hyperLink.form.inputError"):"",children:m.jsx(H.Input,{value:p,onChange:_=>{h(_),_&&(B.current||!i||i===p)&&(Q(_),B.current=!0)},placeholder:v.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===b.KeyCode.ENTER&&Fe()}})}),u===S.SheetHyperLinkType.RANGE&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.inputError"):"",children:m.jsx(Gt.RangeSelector,{unitId:W.getUnitId(),subUnitId:$t,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:p,onChange:Zt,isFocus:ve,onFocus:()=>Ae(!0),actions:ge.current,onRangeSelectorDialogVisibleChange:async _=>{var O,P;if(_)a.type===I.ZEN_EDITOR&&(A.hide(),re.setContextValue(s.FOCUSING_SHEET,!0)),a.type!==I.VIEWING&&C.enableForceKeepVisible(),r(!0);else{if(await x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),a.type===I.ZEN_EDITOR){await N.executeCommand(E.SetSelectionsOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId,selections:[{range:{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col}}]}),A.show(),re.setContextValue(s.FOCUSING_SHEET,!1);const w=(O=q.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(ne.DocBackScrollRenderController),M=(P=he.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:P[0];w&&M&&(w.scrollToRange(M),he.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}C.disableForceKeepVisible(),r(!1)}}})}),u===S.SheetHyperLinkType.SHEET&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.selectError"):"",children:m.jsx(H.Select,{options:$e,value:p,onChange:_=>{var w,M;h(_);const O=(w=$e.find(K=>K.value===_))==null?void 0:w.label,P=(M=$e.find(K=>K.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(Q(O),B.current=!0)}})}),u===S.SheetHyperLinkType.DEFINE_NAME&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.selectError"):"",children:m.jsx(H.Select,{options:Ve,value:p,onChange:_=>{var w,M;h(_);const O=(w=Ve.find(K=>K.value===_))==null?void 0:w.label,P=(M=Ve.find(K=>K.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(Q(O),B.current=!0)}})}),(ie==null?void 0:ie.Form)&&m.jsx(ie.Form,{linkId:e,payload:p,display:i,showError:F,setByPayload:B,setDisplay:_=>{Q(_),B.current=!0},setPayload:h}),m.jsxs("div",{className:Ct.cellLinkEditButtons,children:[m.jsx(H.Button,{onClick:()=>{a&&x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),N.executeCommand(ye.id)},children:v.t("hyperLink.form.cancel")}),m.jsx(H.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Fe()},children:v.t("hyperLink.form.ok")})]})]}):null};Te.componentKey="univer.sheet.cell-link-edit";var $=function(){return $=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},$.apply(this,arguments)},un=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]]);return t},ae=y.forwardRef(function(e,n){var t=e.icon,r=e.id,i=e.className,c=e.extend,o=un(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),u=y.useRef("_".concat(hn()));return bt(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},$({ref:n,className:l},o),c)});function bt(e,n,t,r,i){return y.createElement(e.tag,$($({key:n},pn(e,t,i)),r),(dn(e,t).children||[]).map(function(c,o){return bt(c,"".concat(n,"-").concat(e.tag,"-").concat(o),t,void 0,i)}))}function pn(e,n,t){var r=$({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(c){var o=c[0],l=c[1];typeof l=="string"&&(r[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function dn(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?$($({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?$($({},i),{attrs:$($({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function hn(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var gn={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"}}]},Le=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"all-border-single",ref:n,icon:gn}))});Le.displayName="AllBorderSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Dt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"copy-single",ref:n,icon:vn}))});Dt.displayName="CopySingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Xe=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"link-single",ref:n,icon:_n}))});Xe.displayName="LinkSingle";var Sn={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"}}]},wt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"unlink-single",ref:n,icon:Sn}))});wt.displayName="UnlinkSingle";var mn={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"}}]},Ht=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"write-single",ref:n,icon:mn}))});Ht.displayName="WriteSingle";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Nt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"xlsx",ref:n,icon:In}))});Nt.displayName="Xlsx";function Ut(e){var n,t,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(t=Ut(e[n]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Et(){for(var e,n,t=0,r="",i=arguments.length;t<i;t++)(e=arguments[t])&&(n=Ut(e))&&(r&&(r+=" "),r+=n);return r}const fn="univer-cell-link",yn="univer-cell-link-type",Cn="univer-cell-link-content",En="univer-cell-link-content-error",Rn="univer-cell-link-url",Ln="univer-cell-link-operations",Pn="univer-cell-link-operation",Tn="univer-cell-link-operation-error",G={cellLink:fn,cellLinkType:yn,cellLinkContent:Cn,cellLinkContentError:En,cellLinkUrl:Rn,cellLinkOperations:Ln,cellLinkOperation:Pn,cellLinkOperationError:Tn},kn={[S.SheetHyperLinkType.URL]:m.jsx(Xe,{}),[S.SheetHyperLinkType.SHEET]:m.jsx(Nt,{}),[S.SheetHyperLinkType.RANGE]:m.jsx(Le,{}),[S.SheetHyperLinkType.DEFINE_NAME]:m.jsx(Le,{}),[S.SheetHyperLinkType.INVALID]:m.jsx(Le,{})},Rt=e=>{var x,N;const n=s.useDependency(exports.SheetsHyperLinkPopupService),t=s.useDependency(s.ICommandService),r=s.useDependency(b.IMessageService),i=s.useDependency(s.LocaleService),c=s.useDependency(exports.SheetsHyperLinkResolverService),o=s.useDependency(f.IEditorBridgeService),l=s.useDependency(S.SheetsHyperLinkParserService),u=s.useDependency(b.IZenZoneService),{customRange:d,row:p,col:h,unitId:v,subUnitId:g,editPermission:C,copyPermission:L,type:T}=e;if(!((x=d==null?void 0:d.properties)!=null&&x.url))return null;const a=l.parseHyperLink((N=d.properties.url)!=null?N:""),k=a.type===S.SheetHyperLinkType.INVALID;return m.jsxs("div",{className:G.cellLink,onClick:()=>n.hideCurrentPopup(),children:[m.jsxs("div",{className:Et(G.cellLinkContent,{[G.cellLinkContentError]:k}),onClick:()=>{u.visible||k||c.navigate(a)},children:[m.jsx("div",{className:G.cellLinkType,children:kn[a.type]}),m.jsx(H.Tooltip,{showIfEllipsis:!0,title:a.name,children:m.jsx("span",{className:G.cellLinkUrl,children:a.name})})]}),m.jsxs("div",{className:G.cellLinkOperations,children:[L&&m.jsx("div",{className:Et(G.cellLinkOperation,{[G.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(a.type!==S.SheetHyperLinkType.URL){const D=new URL(window.location.href);D.hash=a.url.slice(1),navigator.clipboard.writeText(D.href)}else navigator.clipboard.writeText(a.url);r.show({content:i.t("hyperLink.message.coped"),type:H.MessageType.Info})}},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:m.jsx(Dt,{})})}),C&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{t.executeCommand(je.id,{unitId:v,subUnitId:g,row:p,col:h,customRangeId:d.rangeId,type:T})},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:m.jsx(Ht,{})})}),m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{const D=T===I.EDITING||T===I.ZEN_EDITOR?S.CancelRichHyperLinkCommand.id:S.CancelHyperLinkCommand.id;t.syncExecuteCommand(D,{unitId:v,subUnitId:g,id:d.rangeId,row:p,column:h,documentId:T===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:m.jsx(wt,{})})})]})]})]})},ke=()=>{var i,c;const e=s.useDependency(exports.SheetsHyperLinkPopupService),[n,t]=y.useState(null),r=s.useDependency(s.IUniverInstanceService);if(y.useEffect(()=>{t(e.currentPopup);const o=e.currentPopup$.subscribe(l=>{t(l)});return()=>{o.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const o=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),d=(c=(i=u==null?void 0:u.p)==null?void 0:i.body)==null?void 0:c.customRanges;return d!=null&&d.length?m.jsx("div",{children:d.map(p=>m.jsx(Rt,{...n,customRange:p},p.rangeId))}):null}return m.jsx(Rt,{...n})};ke.componentKey="univer.sheet.cell-link-popup";var On=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Dn=(e,n,t,r)=>{for(var i=r>1?void 0:r?bn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&On(n,t,i),i},oe=(e,n)=>(t,r)=>n(t,r,e);const Lt=(e,n)=>{var t,r;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&e.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(t,r,i,c,o,l,u){super();Z(this,"_currentPopup",null);Z(this,"_currentPopup$",new R.Subject);Z(this,"currentPopup$",this._currentPopup$.asObservable());Z(this,"_currentEditingPopup",null);Z(this,"_currentEditing$",new R.BehaviorSubject(null));Z(this,"currentEditing$",this._currentEditing$.asObservable());Z(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=c,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&Lt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&Lt(t,r))return;const{unitId:i,subUnitId:c,row:o,col:l,customRangeRect:u,customRange:d}=t;let p;const h={componentKey:ke.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===I.EDITING){if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(t.type===I.ZEN_EDITOR){if(!d)return;p=this._docCanvasPopManagerService.attachPopupToRange({startOffset:d.startIndex,endOffset:d.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)p=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,h,i,c);else{if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,t)}p&&(this._currentPopup={unitId:i,subUnitId:c,disposable:p,row:o,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:d,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,r){var i,c;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((c=(i=this._currentPopup)==null?void 0:i.disposable)==null||c.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,c,o;const t=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(t&&r){const l=this._textSelectionManagerService.getActiveTextRange(),u=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const d=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(c=u.customRanges)==null?void 0:c.filter(v=>v.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let p=l.startOffset,h=l.endOffset;return d.forEach(v=>{p=Math.min(p,v.startIndex),h=Math.max(h,v.endIndex+1)}),{startOffset:p,endOffset:h,collapsed:p===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(p,h))}}return null}get _editPopup(){return{componentKey:Te.componentKey,direction:"vertical",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var o,l,u,d,p;const{unitId:r,subUnitId:i,type:c}=t;if(c===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const v=this._textSelectionManagerService.getActiveTextRange();if(!v)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(v,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const g=(o=h.getBody())==null?void 0:o.dataStream.slice(v.startOffset,v.endOffset);this._currentEditing$.next({...t,label:g})}else if(c===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const v=this._injector.get(Ce.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!v)return;const g=ne.calcDocRangePositions(h,v);if(!(g!=null&&g.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.pop(),this._editPopup,r,i),this._currentEditing$.next({...t,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i);const h=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),v=h==null?void 0:h.getSheetBySheetId(i),g=v==null?void 0:v.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:g!=null&&g.p?s.BuildTextUtils.transform.getPlainText((d=(u=g.p.body)==null?void 0:u.dataStream)!=null?d:""):((p=g==null?void 0:g.v)!=null?p:"").toString()})}}startEditing(t){var l,u,d,p,h,v;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=t;let c,o;if(t.type===I.ZEN_EDITOR){const g=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(c=(d=(u=g==null?void 0:g.getBody())==null?void 0:u.customRanges)==null?void 0:d.find(C=>C.rangeId===t.customRangeId),o=c?(p=g==null?void 0:g.getBody())==null?void 0:p.dataStream.slice(c.startIndex,c.endIndex+1):"",!c||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===I.EDITING){const g=f.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!g||!((h=g.rects)!=null&&h.length))return;c=g.customRange,o=g.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.rects.pop(),this._editPopup,r,i)}else{const g=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),C=g==null?void 0:g.getSheetBySheetId(i),L=C==null?void 0:C.getCellRaw(t.row,t.col),T=g==null?void 0:g.getStyles().getStyleByCell(L),a=T==null?void 0:T.tr,k=f.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((v=k.rects)!=null&&v.length))return;c=k.customRange,o=k.label,a?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:c,label:o})}endEditing(t){var i;const r=this._currentEditing$.getValue();r&&(!t||t===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=Dn([oe(0,s.Inject(f.SheetCanvasPopManagerService)),oe(1,s.Inject(s.Injector)),oe(2,s.IUniverInstanceService),oe(3,f.IEditorBridgeService),oe(4,s.Inject(fe.DocSelectionManagerService)),oe(5,s.Inject(ne.DocCanvasPopManagerService)),oe(6,b.IZenZoneService)],exports.SheetsHyperLinkPopupService);var Ie=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(Ie||{});const wn=new Set([s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE]),Qe=(e,n,t,r)=>{var l,u;const i=n.getCell(t,r);if(i!=null&&i.f||i!=null&&i.si)return 1;const c=e.has(mt.SheetDataValidationModel)?e.get(mt.SheetDataValidationModel):null,o=c==null?void 0:c.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,r);return o&&wn.has(o.type)?!0:(u=(l=i==null?void 0:i.p)==null?void 0:l.drawingsOrder)!=null&&u.length?2:0},Hn=e=>{const n=e.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),r=e.get(E.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,c=r[0].range.startColumn;return Qe(e,t,i,c)===1},Nn=e=>{const n=e.get(fe.DocSelectionManagerService),t=e.get(s.IUniverInstanceService),r=n.getTextRanges();if(!(r!=null&&r.length))return!0;const i=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);return!!(!i||r.every(o=>o.collapsed)||!i.getSelfOrHeaderFooterModel(r[0].segmentId).getBody())},je={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ye={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},Be={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var h;const n=e.get(s.IUniverInstanceService),t=E.getSheetCommandTarget(n),r=e.get(f.IEditorBridgeService);if(!t)return!1;const i=e.get(s.ICommandService),o=e.get(E.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,d=r.isVisible(),p=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(je.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:p?I.ZEN_EDITOR:d.visible?I.EDITING:I.VIEWING})}},ce={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(Hn(e))return!1;const n=e.get(s.ICommandService);return e.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ye.id):n.executeCommand(Be.id)}},et=(e,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const t=e.get(s.IUniverInstanceService),r=(i=e.get(Ce.IRenderManagerService).getRenderById(n))==null?void 0:i.with(ne.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(R.map(()=>{const o=e.get(f.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=E.getSheetCommandTarget(t,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Qe(e,l.worksheet,o.row,o.column)===1?!0:Nn(e)})):R.of(!0)},Mt=e=>{const n=f.getCurrentRangeDisable$(e,{workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},!0),t=e.get(s.IUniverInstanceService),r=e.get(E.SheetsSelectionsService),i=e.has(f.IEditorBridgeService)?e.get(f.IEditorBridgeService):null,c=t.focused$.pipe(R.filter(o=>!!o),R.map(o=>t.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),R.filter(o=>!!o),R.switchMap(o=>o.activeSheet$),R.switchMap(o=>r.selectionMoveEnd$.pipe(R.map(l=>o&&{selections:l,sheet:o}))),R.map(o=>{if(!o)return Ie.DISABLED_BY_CELL;const{selections:l,sheet:u}=o;if(!l.length)return Ie.DISABLED_BY_CELL;const d=l[0].range.startRow,p=l[0].range.startColumn;return Qe(e,u,d,p)}),R.switchMap(o=>{if(o===Ie.DISABLED_BY_CELL)return R.of(!0);const l=(i?i.visible$:R.of(null)).pipe(R.map(d=>d!=null&&d.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=e.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return R.combineLatest([l,u]).pipe(R.switchMap(([d,p])=>d?p?R.of(!0):et(e,d):R.of(o===Ie.ALLOW_ON_EDITING)))}));return n.pipe(R.distinctUntilChanged(),R.switchMap(o=>c.pipe(R.map(l=>o||l))))},Oe={commandId:Be.id,type:b.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},be=e=>`${e}-zen-editor`,Un=e=>({...Oe,id:Oe.commandId,hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Mt(e)}),Mn=e=>({...Oe,id:be(Oe.commandId),hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:et(e)}),De={tooltip:"hyperLink.form.addTitle",commandId:ce.id,type:b.MenuItemType.BUTTON,icon:"LinkSingle"},xn=e=>({...De,id:De.commandId,hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Mt(e)}),jn=e=>({...De,id:be(De.commandId),hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:et(e)}),tt={id:ce.id,binding:b.KeyCode.K|b.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var Bn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,$n=(e,n,t,r)=>{for(var i=r>1?void 0:r?An(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Bn(n,t,i),i},Pt=(e,n)=>(t,r)=>n(t,r,e);let we=class extends s.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:c,target:o,unitId:l,subUnitId:u}=r,d=f.virtualizeDiscreteRanges([c,o]),[p,h]=d.ranges,{mapFunc:v}=d,g={row:p.startRow,col:p.startColumn},C=f.getAutoFillRepeatRange(p,h),L=[],T=[];return C.forEach(a=>{const k=a.repeatStartCell,x=a.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},D={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(x,(V,A)=>{const q=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},N),{row:pe,col:Ee}=v(q.startRow,q.startColumn),re=this._hyperLinkModel.getHyperLinkByLocation(l,u,pe,Ee),de=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},D),{row:he,col:ge}=v(de.startRow,de.startColumn),ie=s.Tools.generateRandomId(),F=this._hyperLinkModel.getHyperLinkByLocation(l,u,he,ge);F&&L.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:F.id}}),(f.APPLY_TYPE.COPY===i||f.APPLY_TYPE.SERIES===i)&&re&&(L.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...re,id:ie,row:he,column:ge}}}),T.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ie}})),F&&T.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:F}})})}),{undos:T,redos:L}},t={id:qe,onFillData:(r,i,c)=>c===f.APPLY_TYPE.COPY||c===f.APPLY_TYPE.ONLY_FORMAT||c===f.APPLY_TYPE.SERIES?n(r,c):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=$n([Pt(0,f.IAutoFillService),Pt(1,s.Inject(S.HyperLinkModel))],we);var Vn=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Zn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Fn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Vn(n,t,i),i},Ye=(e,n)=>(t,r)=>n(t,r,e);let He=class extends s.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===tt.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],rangeTypes:[E.RangeProtectionPermissionEditPoint],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};He=Zn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(f.SheetPermissionInterceptorBaseController))],He);var Wn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Yn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Kn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Wn(n,t,i),i},z=(e,n)=>(t,r)=>n(t,r,e);let Ne=class extends s.Disposable{constructor(e,n,t,r,i,c,o,l,u,d){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionInterceptorBaseController=i,this._commandService=c,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=d,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:r,col:i}=e,c=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(c==null?void 0:c.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookViewPermission],worksheetTypes:[E.WorksheetViewPermission],rangeTypes:[E.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),d=this._permissionService.composePermission([new E.WorkbookCopyPermission(n).id,new E.WorksheetCopyPermission(n,t).id]).every(p=>p.value);return{viewPermission:l,editPermission:u,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(R.debounceTime(200)).subscribe(e=>{var N,D;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:r,col:i}=e,c=this._renderManagerService.getRenderById(n);if(!c)return;const o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(t);if(!l)return;if(!c.with(f.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const d=(N=c==null?void 0:c.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:N.skeleton,p=i,h=r;let v=h,g=p;d&&d.overflowCache.forValue((V,A,q)=>{s.Rectangle.contains(q,{startColumn:p,endColumn:p,startRow:h,endRow:h})&&(v=V,g=A)});const{viewPermission:C,editPermission:L,copyPermission:T}=this._getLinkPermission(e);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const a=l.getCellStyleOnly(v,g),k=o.getStyles().getStyleByCell(a),x=(D=k==null?void 0:k.tr)==null?void 0:D.a;if(!x&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:v,col:g,editPermission:L,copyPermission:T,customRange:e.customRange,customRangeRect:e.rect,type:I.VIEWING,unitId:n,subUnitId:t,showAll:!!x})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(R.switchMap(n=>this._editorBridgeService.visible$.pipe(R.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:c,row:o,column:l}=t,u=this._renderManagerService.getRenderById(r);if(!u)return;const{editPermission:d,viewPermission:p,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:c,row:o,col:l}),v=u.with(ne.DocEventManagerService);p&&(e==null||e.unsubscribe(),e=v.hoverCustomRanges$.pipe(R.debounceTime(200)).subscribe(g=>{var k,x;const C=g.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=C.rects[C.rects.length-1];if(!((x=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(c))==null?void 0:x.skeleton)||!L)return;const a=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:c,row:o,col:l,customRange:C.range,customRangeRect:{left:L.left+a.left,top:L.top+a.top,bottom:L.bottom+a.top,right:L.right+a.left},editPermission:d,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(R.switchMap(e=>{const n=e===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ne.DocEventManagerService).hoverCustomRanges$.pipe(R.debounceTime(200)):new R.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:r,sheetId:i,row:c,column:o}=t,{editPermission:l,viewPermission:u,copyPermission:d}=this._getLinkPermission({unitId:r,subUnitId:i,row:c,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:r,subUnitId:i,row:c,col:o,customRange:n.range,editPermission:l,copyPermission:d})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const e=[E.ClearSelectionContentCommand.id,E.ClearSelectionAllCommand.id,E.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ne=Yn([z(0,s.Inject(f.HoverManagerService)),z(1,s.Inject(exports.SheetsHyperLinkPopupService)),z(2,s.Inject(Ce.IRenderManagerService)),z(3,s.Inject(s.IPermissionService)),z(4,s.Inject(f.SheetPermissionInterceptorBaseController)),z(5,s.ICommandService),z(6,f.IEditorBridgeService),z(7,s.Inject(fe.DocSelectionManagerService)),z(8,s.IUniverInstanceService),z(9,b.IZenZoneService)],Ne);var Gn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,xt=(e,n,t,r)=>{for(var i=r>1?void 0:r?zn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Gn(n,t,i),i},Ge=(e,n)=>(t,r)=>n(t,r,e);let ze=class extends s.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(R.debounceTime(16)).subscribe(()=>{e()}))}};ze=xt([Ge(1,s.Inject(S.HyperLinkModel))],ze);let Ue=class extends s.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(E.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:r,col:i,unitId:c,subUnitId:o}=n,l=this._hyperLinkModel.getHyperLinkByLocation(c,o,r,i);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};Ue=xt([Ge(0,s.Inject(E.SheetInterceptorService)),Ge(1,s.Inject(S.HyperLinkModel))],Ue);const qn={[b.RibbonStartGroup.OTHERS]:{[ce.id]:{order:2,menuItemFactory:xn},[be(ce.id)]:{order:2,menuItemFactory:jn}},[b.ContextMenuPosition.MAIN_AREA]:{[b.ContextMenuGroup.OTHERS]:{order:1,[ce.id]:{order:0,menuItemFactory:Un},[be(ce.id)]:{order:0,menuItemFactory:Mn}}}};var Jn=Object.defineProperty,Xn=Object.getOwnPropertyDescriptor,Qn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Xn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Jn(n,t,i),i},me=(e,n)=>(t,r)=>n(t,r,e);let Me=class extends s.Disposable{constructor(e,n,t,r,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ke,ke.componentKey],[Te,Te.componentKey],[Xe,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[je,ye,Be,ce].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(qn)}_initShortCut(){this._shortcutService.registerShortcut(tt)}};Me=Qn([me(0,s.Inject(b.ComponentManager)),me(1,s.ICommandService),me(2,b.IMenuManagerService),me(3,s.Inject(s.Injector)),me(4,s.Inject(b.IShortcutService))],Me);var er=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,nr=(e,n,t,r)=>{for(var i=r>1?void 0:r?tr(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&er(n,t,i),i},Tt=(e,n)=>(t,r)=>n(t,r,e);let xe=class extends s.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};xe=nr([Tt(0,s.Inject(S.SheetsHyperLinkParserService)),Tt(1,s.Inject(exports.SheetsHyperLinkResolverService))],xe);var jt=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ir=(e,n,t)=>n in e?jt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,sr=(e,n,t,r)=>{for(var i=r>1?void 0:r?rr(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&jt(n,t,i),i},kt=(e,n)=>(t,r)=>n(t,r,e),Bt=(e,n,t)=>ir(e,typeof n!="symbol"?n+"":n,t);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=It,t,r){super(),this._config=n,this._injector=t,this._configService=r;const{menu:i,...c}=s.merge({},It,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ot,c)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[Je],[Ue],[Ne],[Me],[we],[exports.SheetsHyperLinkCopyPasteController],[He],[xe]].forEach(t=>this._injector.add(t)),this._injector.get(Ue)}onReady(){this._injector.get(Ce.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[ze]),this._injector.get(we),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(Me)}onRendered(){this._injector.get(He),this._injector.get(xe),this._injector.get(Ne)}};Bt(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",qe);Bt(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=sr([s.DependentOn(S.UniverSheetsHyperLinkPlugin,ne.UniverDocsUIPlugin),kt(1,s.Inject(s.Injector)),kt(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=ye;exports.InsertHyperLinkOperation=Be;exports.InsertLinkShortcut=tt;exports.OpenHyperLinkEditPanelOperation=je;exports.SheetsHyperLinkSidePanelService=Je;
9
+ */var ft;function on(){if(ft)return Se;ft=1;var e=y,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function o(l,u,d){var p,h={},v=null,g=null;d!==void 0&&(v=""+d),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(g=u.ref);for(p in u)r.call(u,p)&&!c.hasOwnProperty(p)&&(h[p]=u[p]);if(l&&l.defaultProps)for(p in u=l.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:n,type:l,key:v,ref:g,props:h,_owner:i.current}}return Se.Fragment=t,Se.jsx=o,Se.jsxs=o,Se}var yt;function cn(){return yt||(yt=1,Ke.exports=on()),Ke.exports}var m=cn();class Je extends s.Disposable{constructor(){super(...arguments);Z(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==S.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(i=>i.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:r}=this;r.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const an="univer-cell-link-edit",ln="univer-cell-link-edit-buttons",Ct={cellLinkEdit:an,cellLinkEditButtons:ln},Te=()=>{var rt;const[e,n]=y.useState(""),[t,r]=y.useState(!1),[i,c]=y.useState(""),[o,l]=y.useState(!0),[u,d]=y.useState(S.SheetHyperLinkType.URL),[p,h]=y.useState(""),v=s.useDependency(s.LocaleService),g=s.useDependency(X.IDefinedNamesService),C=s.useDependency(f.IEditorBridgeService),L=s.useDependency(s.IUniverInstanceService),T=s.useDependency(exports.SheetsHyperLinkPopupService),a=b.useObservable(T.currentEditing$),k=s.useDependency(S.SheetsHyperLinkParserService),x=s.useDependency(exports.SheetsHyperLinkResolverService),N=s.useDependency(s.ICommandService),D=s.useDependency(Je),V=y.useMemo(()=>D.getOptions(),[D]),A=s.useDependency(b.IZenZoneService),q=s.useDependency(Ce.IRenderManagerService),pe=s.useDependency(f.IMarkSelectionService),Ee=s.useDependency(fe.DocSelectionManagerService),re=s.useDependency(s.IContextService),de=s.useDependency(s.ThemeService),he=s.useDependency(fe.DocSelectionManagerService),ge=y.useRef({}),ie=y.useMemo(()=>{if(!D.isBuiltInLinkType(u))return D.getCustomHyperLink(u)},[D,u]),[F,At]=y.useState(!1),[ve,Ae]=y.useState(!1),B=y.useRef(!1),W=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),$t=(W==null?void 0:W.getActiveSheet().getSheetId())||"",Q=y.useCallback(_=>{c(_.replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(s.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[c]);y.useEffect(()=>{var _,O,P,w,M,K,it,st,ot,ct,at,lt,ut,pt,dt,ht,gt;if((a==null?void 0:a.row)!==void 0&&a.col!==void 0){const{customRange:se,row:Ze,col:We}=a;let{label:J}=a;typeof J=="number"&&(J=`${J}`);let Y;if(se)Y={id:(_=se==null?void 0:se.rangeId)!=null?_:"",display:J!=null?J:"",payload:(P=(O=se==null?void 0:se.properties)==null?void 0:O.url)!=null?P:"",row:Ze,column:We};else if(a.type===I.VIEWING){const U=L.getUnit(a.unitId),te=U==null?void 0:U.getSheetBySheetId(a.subUnitId),j=te==null?void 0:te.getCellRaw(a.row,a.col),le=(K=(M=(w=j==null?void 0:j.p)==null?void 0:w.body)==null?void 0:M.customRanges)==null?void 0:K.find(_t=>{var St;return _t.rangeType===s.CustomRangeType.HYPERLINK&&((St=_t.properties)==null?void 0:St.url)}),_e=j==null?void 0:j.v;j&&(!s.BuildTextUtils.transform.isEmptyDocument((st=(it=j.p)==null?void 0:it.body)==null?void 0:st.dataStream)||s.Tools.isDefine(_e))&&l(!1),Y={id:"",display:"",payload:(ct=(ot=le==null?void 0:le.properties)==null?void 0:ot.url)!=null?ct:"",row:Ze,column:We}}else{const U=L.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC),te=Ee.getActiveTextRange(),j=U==null?void 0:U.getBody(),le=te&&j?te:null,_e=le&&((lt=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(le,(at=j==null?void 0:j.customRanges)!=null?at:[]))==null?void 0:lt[0]);l(!1),Y={id:"",display:J!=null?J:"",payload:(pt=(ut=_e==null?void 0:_e.properties)==null?void 0:ut.url)!=null?pt:"",row:Ze,column:We}}n(Y.id);const vt=D.findCustomHyperLink(Y);if(vt){const U=vt.convert(Y);d(U.type),h(U.payload),Q(U.display);return}Q(Y.display);const ee=k.parseHyperLink(Y.payload);switch(d(ee.type===S.SheetHyperLinkType.INVALID?S.SheetHyperLinkType.RANGE:ee.type),ee.type){case S.SheetHyperLinkType.URL:{h(ee.url),ee.url===Y.display&&(B.current=!0);break}case S.SheetHyperLinkType.RANGE:{const U=ee.searchObj,te=U.gid&&(gt=(ht=(dt=L.getUnit(a.unitId))==null?void 0:dt.getSheetBySheetId(U.gid))==null?void 0:ht.getName())!=null?gt:"",j=X.serializeRangeWithSheet(te,X.deserializeRangeWithSheet(U.range).range);h(j),j===Y.display&&(B.current=!0);break}case S.SheetHyperLinkType.SHEET:{const U=ee.searchObj;h(U.gid);break}case S.SheetHyperLinkType.DEFINE_NAME:{const U=ee.searchObj;h(U.rangeid);break}default:h("");break}}},[a,x,D,Ee,L]),y.useEffect(()=>{let _=null;if(a&&!a.customRangeId&&a.type===I.VIEWING&&s.Tools.isDefine(a.row)&&s.Tools.isDefine(a.col)){const O=L.getUnit(a.unitId,s.UniverInstanceType.UNIVER_SHEET),P=O==null?void 0:O.getSheetBySheetId(a.subUnitId),w=P==null?void 0:P.getMergedCell(a.row,a.col),M=new s.ColorKit(de.getCurrentTheme().hyacinth500).toRgb();_=pe.addShape({range:w!=null?w:{startColumn:a.col,endColumn:a.col,startRow:a.row,endRow:a.row},style:{fill:`rgb(${M.r}, ${M.g}, ${M.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{_&&pe.removeShape(_)}},[a,pe,de,L]),y.useEffect(()=>{Ae(u===S.SheetHyperLinkType.RANGE)},[u]),y.useEffect(()=>{const _=(a==null?void 0:a.type)===I.ZEN_EDITOR?q.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY):q.getRenderById(C.getCurrentEditorId()),O=new s.DisposableCollection;if(_){const P=_.with(ne.DocSelectionRenderService);P.setReserveRangesStatus(!0),O.add(()=>{P.setReserveRangesStatus(!1)})}return()=>{C.disableForceKeepVisible(),O.dispose()}},[a==null?void 0:a.type,C,q]),y.useEffect(()=>(T.setIsKeepVisible(ve),()=>{T.setIsKeepVisible(!1)}),[ve,T]),y.useEffect(()=>()=>{A.temporaryHidden&&(A.show(),re.setContextValue(s.FOCUSING_SHEET,!1))},[re,A]),y.useEffect(()=>{if(ve)return C.enableForceKeepVisible(),()=>{C.disableForceKeepVisible()}},[ve,C]);const Vt=[{label:v.t("hyperLink.form.link"),value:S.SheetHyperLinkType.URL},{label:v.t("hyperLink.form.range"),value:S.SheetHyperLinkType.RANGE},{label:v.t("hyperLink.form.worksheet"),value:S.SheetHyperLinkType.SHEET},{label:v.t("hyperLink.form.definedName"),value:S.SheetHyperLinkType.DEFINE_NAME},...V];if(!W)return;const Ft=W.getHiddenWorksheets(),$e=W.getSheets().map(_=>({label:_.getName(),value:_.getSheetId()})).filter(_=>Ft.indexOf(_.value)===-1),Ve=Object.values((rt=g.getDefinedNameMap(W.getUnitId()))!=null?rt:{}).map(_=>({label:_.name,value:_.id})),nt=(_,O)=>{if(_===S.SheetHyperLinkType.URL)return Jt(O);if(_===S.SheetHyperLinkType.RANGE){const P=X.deserializeRangeWithSheet(O),w=W.getSheetBySheetName(P.sheetName);if(w)return`#gid=${w.getSheetId()}&range=${X.serializeRange(P.range)}`}return`#${_}=${O}`},Zt=b.useEvent(_=>{var M;const P=_.split(",").map(X.deserializeRangeWithSheet)[0];if(!P||!s.isValidRange(P.range))return;P.sheetName||(P.sheetName=((M=W.getActiveSheet())==null?void 0:M.getName())||"");const w=X.serializeRangeToRefString(P);h(w),w&&(B.current||!i)&&(Q(w),B.current=!0)}),Fe=async()=>{if(o&&!i||!p||u===S.SheetHyperLinkType.URL&&!Pe(p)){At(!0);return}if(a)if(e){const _=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.UpdateRichHyperLinkCommand.id:S.UpdateHyperLinkCommand.id;await N.executeCommand(_,{id:e,unitId:a.unitId,subUnitId:a.subUnitId,payload:{display:o?i:"",payload:nt(u,p)},row:a.row,column:a.col,documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}else{const _=a.type===I.ZEN_EDITOR||a.type===I.EDITING?S.AddRichHyperLinkCommand.id:S.AddHyperLinkCommand.id;await N.executeCommand(_,{unitId:a.unitId,subUnitId:a.subUnitId,link:{id:s.generateRandomId(),row:a.row,column:a.col,payload:nt(u,p),display:o?i:""},documentId:a.type===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:C.getCurrentEditorId()})}if((a==null?void 0:a.type)===I.VIEWING){await N.executeCommand(E.SetWorksheetActiveOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId});const _=1;await N.executeCommand(f.ScrollToRangeOperation.id,{range:{startRow:Math.max(a.row-_,0),endRow:a.row+_,startColumn:Math.max(a.col-_,0),endColumn:a.col+_}})}N.executeCommand(ye.id)},Wt=_=>{var P;if(u!==S.SheetHyperLinkType.RANGE)return;const O=(P=ge.current)==null?void 0:P.handleOutClick;O&&O(_,()=>Ae(!1))};return a?m.jsxs("div",{className:Ct.cellLinkEdit,style:{display:t?"none":"block"},onClick:Wt,children:[o?m.jsx(H.FormLayout,{label:v.t("hyperLink.form.label"),error:F&&!i?v.t("hyperLink.form.inputError"):"",children:m.jsx(H.Input,{value:i,onChange:_=>{Q(_),B.current=!1},placeholder:v.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===b.KeyCode.ENTER&&Fe()}})}):null,m.jsx(H.FormLayout,{label:v.t("hyperLink.form.type"),children:m.jsx(H.Select,{options:Vt,value:u,onChange:_=>{d(_),h("")}})}),u===S.SheetHyperLinkType.URL&&m.jsx(H.FormLayout,{error:F?p?Pe(p)?"":v.t("hyperLink.form.linkError"):v.t("hyperLink.form.inputError"):"",children:m.jsx(H.Input,{value:p,onChange:_=>{h(_),_&&(B.current||!i||i===p)&&(Q(_),B.current=!0)},placeholder:v.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:_=>{_.keyCode===b.KeyCode.ENTER&&Fe()}})}),u===S.SheetHyperLinkType.RANGE&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.inputError"):"",children:m.jsx(Gt.RangeSelector,{unitId:W.getUnitId(),subUnitId:$t,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:p,onChange:Zt,isFocus:ve,onFocus:()=>Ae(!0),actions:ge.current,onRangeSelectorDialogVisibleChange:async _=>{var O,P;if(_)a.type===I.ZEN_EDITOR&&(A.hide(),re.setContextValue(s.FOCUSING_SHEET,!0)),a.type!==I.VIEWING&&C.enableForceKeepVisible(),r(!0);else{if(await x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),a.type===I.ZEN_EDITOR){await N.executeCommand(E.SetSelectionsOperation.id,{unitId:a.unitId,subUnitId:a.subUnitId,selections:[{range:{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col}}]}),A.show(),re.setContextValue(s.FOCUSING_SHEET,!1);const w=(O=q.getRenderById(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:O.with(ne.DocBackScrollRenderController),M=(P=he.getTextRanges({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:P[0];w&&M&&(w.scrollToRange(M),he.refreshSelection({unitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}C.disableForceKeepVisible(),r(!1)}}})}),u===S.SheetHyperLinkType.SHEET&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.selectError"):"",children:m.jsx(H.Select,{options:$e,value:p,onChange:_=>{var w,M;h(_);const O=(w=$e.find(K=>K.value===_))==null?void 0:w.label,P=(M=$e.find(K=>K.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(Q(O),B.current=!0)}})}),u===S.SheetHyperLinkType.DEFINE_NAME&&m.jsx(H.FormLayout,{error:F&&!p?v.t("hyperLink.form.selectError"):"",children:m.jsx(H.Select,{options:Ve,value:p,onChange:_=>{var w,M;h(_);const O=(w=Ve.find(K=>K.value===_))==null?void 0:w.label,P=(M=Ve.find(K=>K.value===p))==null?void 0:M.label;O&&(B.current||!i||i===P)&&(Q(O),B.current=!0)}})}),(ie==null?void 0:ie.Form)&&m.jsx(ie.Form,{linkId:e,payload:p,display:i,showError:F,setByPayload:B,setDisplay:_=>{Q(_),B.current=!0},setPayload:h}),m.jsxs("div",{className:Ct.cellLinkEditButtons,children:[m.jsx(H.Button,{onClick:()=>{a&&x.navigateToRange(a.unitId,a.subUnitId,{startRow:a.row,endRow:a.row,startColumn:a.col,endColumn:a.col},!0),N.executeCommand(ye.id)},children:v.t("hyperLink.form.cancel")}),m.jsx(H.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{Fe()},children:v.t("hyperLink.form.ok")})]})]}):null};Te.componentKey="univer.sheet.cell-link-edit";var $=function(){return $=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++){n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},$.apply(this,arguments)},un=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(t[r[i]]=e[r[i]]);return t},ae=y.forwardRef(function(e,n){var t=e.icon,r=e.id,i=e.className,c=e.extend,o=un(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(r," ").concat(i||"").trim(),u=y.useRef("_".concat(hn()));return bt(t,"".concat(r),{defIds:t.defIds,idSuffix:u.current},$({ref:n,className:l},o),c)});function bt(e,n,t,r,i){return y.createElement(e.tag,$($({key:n},pn(e,t,i)),r),(dn(e,t).children||[]).map(function(c,o){return bt(c,"".concat(n,"-").concat(e.tag,"-").concat(o),t,void 0,i)}))}function pn(e,n,t){var r=$({},e.attrs);t!=null&&t.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=t.colorChannel1);var i=n.defIds;return!i||i.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+n.idSuffix),Object.entries(r).forEach(function(c){var o=c[0],l=c[1];typeof l=="string"&&(r[o]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),r}function dn(e,n){var t,r=n.defIds;return!r||r.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?$($({},e),{children:e.children.map(function(i){return typeof i.attrs.id=="string"&&r&&r.indexOf(i.attrs.id)>-1?$($({},i),{attrs:$($({},i.attrs),{id:i.attrs.id+n.idSuffix})}):i})}):e}function hn(){return Math.random().toString(36).substring(2,8)}ae.displayName="UniverIcon";var gn={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"}}]},Le=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"all-border-single",ref:n,icon:gn}))});Le.displayName="AllBorderSingle";var vn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Dt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"copy-single",ref:n,icon:vn}))});Dt.displayName="CopySingle";var _n={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},Xe=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"link-single",ref:n,icon:_n}))});Xe.displayName="LinkSingle";var Sn={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"}}]},wt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"unlink-single",ref:n,icon:Sn}))});wt.displayName="UnlinkSingle";var mn={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"}}]},Ht=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"write-single",ref:n,icon:mn}))});Ht.displayName="WriteSingle";var In={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Nt=y.forwardRef(function(e,n){return y.createElement(ae,Object.assign({},e,{id:"xlsx",ref:n,icon:In}))});Nt.displayName="Xlsx";function Ut(e){var n,t,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(n=0;n<i;n++)e[n]&&(t=Ut(e[n]))&&(r&&(r+=" "),r+=t)}else for(t in e)e[t]&&(r&&(r+=" "),r+=t);return r}function Et(){for(var e,n,t=0,r="",i=arguments.length;t<i;t++)(e=arguments[t])&&(n=Ut(e))&&(r&&(r+=" "),r+=n);return r}const fn="univer-cell-link",yn="univer-cell-link-type",Cn="univer-cell-link-content",En="univer-cell-link-content-error",Rn="univer-cell-link-url",Ln="univer-cell-link-operations",Pn="univer-cell-link-operation",Tn="univer-cell-link-operation-error",G={cellLink:fn,cellLinkType:yn,cellLinkContent:Cn,cellLinkContentError:En,cellLinkUrl:Rn,cellLinkOperations:Ln,cellLinkOperation:Pn,cellLinkOperationError:Tn},kn={[S.SheetHyperLinkType.URL]:m.jsx(Xe,{}),[S.SheetHyperLinkType.SHEET]:m.jsx(Nt,{}),[S.SheetHyperLinkType.RANGE]:m.jsx(Le,{}),[S.SheetHyperLinkType.DEFINE_NAME]:m.jsx(Le,{}),[S.SheetHyperLinkType.INVALID]:m.jsx(Le,{})},Rt=e=>{var x,N;const n=s.useDependency(exports.SheetsHyperLinkPopupService),t=s.useDependency(s.ICommandService),r=s.useDependency(b.IMessageService),i=s.useDependency(s.LocaleService),c=s.useDependency(exports.SheetsHyperLinkResolverService),o=s.useDependency(f.IEditorBridgeService),l=s.useDependency(S.SheetsHyperLinkParserService),u=s.useDependency(b.IZenZoneService),{customRange:d,row:p,col:h,unitId:v,subUnitId:g,editPermission:C,copyPermission:L,type:T}=e;if(!((x=d==null?void 0:d.properties)!=null&&x.url))return null;const a=l.parseHyperLink((N=d.properties.url)!=null?N:""),k=a.type===S.SheetHyperLinkType.INVALID;return m.jsxs("div",{className:G.cellLink,onClick:()=>n.hideCurrentPopup(),children:[m.jsxs("div",{className:Et(G.cellLinkContent,{[G.cellLinkContentError]:k}),onClick:()=>{u.visible||k||c.navigate(a)},children:[m.jsx("div",{className:G.cellLinkType,children:kn[a.type]}),m.jsx(H.Tooltip,{showIfEllipsis:!0,title:a.name,asChild:!0,children:m.jsx("span",{className:G.cellLinkUrl,children:a.name})})]}),m.jsxs("div",{className:G.cellLinkOperations,children:[L&&m.jsx("div",{className:Et(G.cellLinkOperation,{[G.cellLinkOperationError]:k}),onClick:()=>{if(!k){if(a.type!==S.SheetHyperLinkType.URL){const D=new URL(window.location.href);D.hash=a.url.slice(1),navigator.clipboard.writeText(D.href)}else navigator.clipboard.writeText(a.url);r.show({content:i.t("hyperLink.message.coped"),type:H.MessageType.Info})}},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.copy"),children:m.jsx(Dt,{})})}),C&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{t.executeCommand(je.id,{unitId:v,subUnitId:g,row:p,col:h,customRangeId:d.rangeId,type:T})},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.edit"),children:m.jsx(Ht,{})})}),m.jsx("div",{className:G.cellLinkOperation,onClick:()=>{const D=T===I.EDITING||T===I.ZEN_EDITOR?S.CancelRichHyperLinkCommand.id:S.CancelHyperLinkCommand.id;t.syncExecuteCommand(D,{unitId:v,subUnitId:g,id:d.rangeId,row:p,column:h,documentId:T===I.ZEN_EDITOR?s.DOCS_ZEN_EDITOR_UNIT_ID_KEY:o.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:m.jsx(H.Tooltip,{placement:"bottom",title:i.t("hyperLink.popup.cancel"),children:m.jsx(wt,{})})})]})]})]})},ke=()=>{var i,c;const e=s.useDependency(exports.SheetsHyperLinkPopupService),[n,t]=y.useState(null),r=s.useDependency(s.IUniverInstanceService);if(y.useEffect(()=>{t(e.currentPopup);const o=e.currentPopup$.subscribe(l=>{t(l)});return()=>{o.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const o=r.getUnit(n.unitId,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),d=(c=(i=u==null?void 0:u.p)==null?void 0:i.body)==null?void 0:c.customRanges;return d!=null&&d.length?m.jsx("div",{children:d.map(p=>m.jsx(Rt,{...n,customRange:p},p.rangeId))}):null}return m.jsx(Rt,{...n})};ke.componentKey="univer.sheet.cell-link-popup";var On=Object.defineProperty,bn=Object.getOwnPropertyDescriptor,Dn=(e,n,t,r)=>{for(var i=r>1?void 0:r?bn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&On(n,t,i),i},oe=(e,n)=>(t,r)=>n(t,r,e);const Lt=(e,n)=>{var t,r;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((r=n.customRange)==null?void 0:r.rangeId)&&e.type===n.type};exports.SheetsHyperLinkPopupService=class extends s.Disposable{constructor(t,r,i,c,o,l,u){super();Z(this,"_currentPopup",null);Z(this,"_currentPopup$",new R.Subject);Z(this,"currentPopup$",this._currentPopup$.asObservable());Z(this,"_currentEditingPopup",null);Z(this,"_currentEditing$",new R.BehaviorSubject(null));Z(this,"currentEditing$",this._currentEditing$.asObservable());Z(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=r,this._univerInstanceService=i,this._editorBridgeService=c,this._textSelectionManagerService=o,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&Lt(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==I.ZEN_EDITOR&&this._zenZoneService.visible))return;const r=this._currentEditing$.getValue();if(r&&Lt(t,r))return;const{unitId:i,subUnitId:c,row:o,col:l,customRangeRect:u,customRange:d}=t;let p;const h={componentKey:ke.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===I.EDITING){if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(t.type===I.ZEN_EDITOR){if(!d)return;p=this._docCanvasPopManagerService.attachPopupToRange({startOffset:d.startIndex,endOffset:d.endIndex+1,collapsed:!1},h,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)p=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,h,i,c);else{if(!d)return;p=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,t)}p&&(this._currentPopup={unitId:i,subUnitId:c,disposable:p,row:o,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:d,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,r){var i,c;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||r)&&((c=(i=this._currentPopup)==null?void 0:i.disposable)==null||c.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var i,c,o;const t=this._editorBridgeService.isVisible().visible,r=this._editorBridgeService.getEditCellState();if(t&&r){const l=this._textSelectionManagerService.getActiveTextRange(),u=(i=r.documentLayoutObject.documentModel)==null?void 0:i.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:s.BuildTextUtils.transform.getPlainText(u.dataStream)};const d=s.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(o=(c=u.customRanges)==null?void 0:c.filter(v=>v.rangeType===s.CustomRangeType.HYPERLINK))!=null?o:[]);let p=l.startOffset,h=l.endOffset;return d.forEach(v=>{p=Math.min(p,v.startIndex),h=Math.max(h,v.endIndex+1)}),{startOffset:p,endOffset:h,collapsed:p===h,label:s.BuildTextUtils.transform.getPlainText(u.dataStream.slice(p,h))}}return null}get _editPopup(){return{componentKey:Te.componentKey,direction:"vertical",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var o,l,u,d,p;const{unitId:r,subUnitId:i,type:c}=t;if(c===I.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(!h)return;const v=this._textSelectionManagerService.getActiveTextRange();if(!v)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(v,this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const g=(o=h.getBody())==null?void 0:o.dataStream.slice(v.startOffset,v.endOffset);this._currentEditing$.next({...t,label:g})}else if(c===I.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const v=this._injector.get(Ce.IRenderManagerService).getRenderById(s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!v)return;const g=ne.calcDocRangePositions(h,v);if(!(g!=null&&g.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.pop(),this._editPopup,r,i),this._currentEditing$.next({...t,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i);const h=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),v=h==null?void 0:h.getSheetBySheetId(i),g=v==null?void 0:v.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:g!=null&&g.p?s.BuildTextUtils.transform.getPlainText((d=(u=g.p.body)==null?void 0:u.dataStream)!=null?d:""):((p=g==null?void 0:g.v)!=null?p:"").toString()})}}startEditing(t){var l,u,d,p,h,v;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:r,subUnitId:i}=t;let c,o;if(t.type===I.ZEN_EDITOR){const g=this._univerInstanceService.getUnit(s.DOCS_ZEN_EDITOR_UNIT_ID_KEY,s.UniverInstanceType.UNIVER_DOC);if(c=(d=(u=g==null?void 0:g.getBody())==null?void 0:u.customRanges)==null?void 0:d.find(C=>C.rangeId===t.customRangeId),o=c?(p=g==null?void 0:g.getBody())==null?void 0:p.dataStream.slice(c.startIndex,c.endIndex+1):"",!c||!o)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:c.startIndex,endOffset:c.endIndex,collapsed:!1},this._editPopup,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===I.EDITING){const g=f.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!g||!((h=g.rects)!=null&&h.length))return;c=g.customRange,o=g.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:c.startIndex,endOffset:c.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(g.rects.pop(),this._editPopup,r,i)}else{const g=this._univerInstanceService.getUnit(r,s.UniverInstanceType.UNIVER_SHEET),C=g==null?void 0:g.getSheetBySheetId(i),L=C==null?void 0:C.getCellRaw(t.row,t.col),T=g==null?void 0:g.getStyles().getStyleByCell(L),a=T==null?void 0:T.tr,k=f.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!k||!((v=k.rects)!=null&&v.length))return;c=k.customRange,o=k.label,a?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,r,i):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(k.rects.pop(),this._editPopup,{unitId:r,subUnitId:i,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:c,label:o})}endEditing(t){var i;const r=this._currentEditing$.getValue();r&&(!t||t===r.type)&&((i=this._currentEditingPopup)==null||i.dispose(),this._currentEditing$.next(null))}};exports.SheetsHyperLinkPopupService=Dn([oe(0,s.Inject(f.SheetCanvasPopManagerService)),oe(1,s.Inject(s.Injector)),oe(2,s.IUniverInstanceService),oe(3,f.IEditorBridgeService),oe(4,s.Inject(fe.DocSelectionManagerService)),oe(5,s.Inject(ne.DocCanvasPopManagerService)),oe(6,b.IZenZoneService)],exports.SheetsHyperLinkPopupService);var Ie=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(Ie||{});const wn=new Set([s.DataValidationType.CHECKBOX,s.DataValidationType.LIST,s.DataValidationType.LIST_MULTIPLE]),Qe=(e,n,t,r)=>{var l,u;const i=n.getCell(t,r);if(i!=null&&i.f||i!=null&&i.si)return 1;const c=e.has(mt.SheetDataValidationModel)?e.get(mt.SheetDataValidationModel):null,o=c==null?void 0:c.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,r);return o&&wn.has(o.type)?!0:(u=(l=i==null?void 0:i.p)==null?void 0:l.drawingsOrder)!=null&&u.length?2:0},Hn=e=>{const n=e.get(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),r=e.get(E.SheetsSelectionsService).getCurrentSelections();if(!r.length)return!0;const i=r[0].range.startRow,c=r[0].range.startColumn;return Qe(e,t,i,c)===1},Nn=e=>{const n=e.get(fe.DocSelectionManagerService),t=e.get(s.IUniverInstanceService),r=n.getTextRanges();if(!(r!=null&&r.length))return!0;const i=t.getCurrentUnitForType(s.UniverInstanceType.UNIVER_DOC);return!!(!i||r.every(o=>o.collapsed)||!i.getSelfOrHeaderFooterModel(r[0].segmentId).getBody())},je={type:s.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(exports.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},ye={type:s.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(exports.SheetsHyperLinkPopupService).endEditing(),!0}},Be={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var h;const n=e.get(s.IUniverInstanceService),t=E.getSheetCommandTarget(n),r=e.get(f.IEditorBridgeService);if(!t)return!1;const i=e.get(s.ICommandService),o=e.get(E.SheetsSelectionsService).getCurrentLastSelection();if(!o)return!1;const l=o.range.startRow,u=o.range.startColumn,d=r.isVisible(),p=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return i.executeCommand(je.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:p?I.ZEN_EDITOR:d.visible?I.EDITING:I.VIEWING})}},ce={type:s.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(Hn(e))return!1;const n=e.get(s.ICommandService);return e.get(exports.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(ye.id):n.executeCommand(Be.id)}},et=(e,n=s.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var i;const t=e.get(s.IUniverInstanceService),r=(i=e.get(Ce.IRenderManagerService).getRenderById(n))==null?void 0:i.with(ne.DocSelectionRenderService);return r?r.textSelectionInner$.pipe(R.map(()=>{const o=e.get(f.IEditorBridgeService).getEditCellState();if(!o)return!0;const l=E.getSheetCommandTarget(t,{unitId:o.unitId,subUnitId:o.sheetId});return!(l!=null&&l.worksheet)||Qe(e,l.worksheet,o.row,o.column)===1?!0:Nn(e)})):R.of(!0)},Mt=e=>{const n=f.getCurrentRangeDisable$(e,{workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},!0),t=e.get(s.IUniverInstanceService),r=e.get(E.SheetsSelectionsService),i=e.has(f.IEditorBridgeService)?e.get(f.IEditorBridgeService):null,c=t.focused$.pipe(R.filter(o=>!!o),R.map(o=>t.getUnit(o,s.UniverInstanceType.UNIVER_SHEET)),R.filter(o=>!!o),R.switchMap(o=>o.activeSheet$),R.switchMap(o=>r.selectionMoveEnd$.pipe(R.map(l=>o&&{selections:l,sheet:o}))),R.map(o=>{if(!o)return Ie.DISABLED_BY_CELL;const{selections:l,sheet:u}=o;if(!l.length)return Ie.DISABLED_BY_CELL;const d=l[0].range.startRow,p=l[0].range.startColumn;return Qe(e,u,d,p)}),R.switchMap(o=>{if(o===Ie.DISABLED_BY_CELL)return R.of(!0);const l=(i?i.visible$:R.of(null)).pipe(R.map(d=>d!=null&&d.visible?s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=e.get(s.IContextService).subscribeContextValue$(s.FOCUSING_FX_BAR_EDITOR);return R.combineLatest([l,u]).pipe(R.switchMap(([d,p])=>d?p?R.of(!0):et(e,d):R.of(o===Ie.ALLOW_ON_EDITING)))}));return n.pipe(R.distinctUntilChanged(),R.switchMap(o=>c.pipe(R.map(l=>o||l))))},Oe={commandId:Be.id,type:b.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},be=e=>`${e}-zen-editor`,Un=e=>({...Oe,id:Oe.commandId,hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Mt(e)}),Mn=e=>({...Oe,id:be(Oe.commandId),hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:et(e)}),De={tooltip:"hyperLink.form.addTitle",commandId:ce.id,type:b.MenuItemType.BUTTON,icon:"LinkSingle"},xn=e=>({...De,id:De.commandId,hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_SHEET),disabled$:Mt(e)}),jn=e=>({...De,id:be(De.commandId),hidden$:b.getMenuHiddenObservable(e,s.UniverInstanceType.UNIVER_DOC,s.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:et(e)}),tt={id:ce.id,binding:b.KeyCode.K|b.MetaKeys.CTRL_COMMAND,preconditions:f.whenSheetEditorFocused};var Bn=Object.defineProperty,An=Object.getOwnPropertyDescriptor,$n=(e,n,t,r)=>{for(var i=r>1?void 0:r?An(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Bn(n,t,i),i},Pt=(e,n)=>(t,r)=>n(t,r,e);let we=class extends s.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(r,i)=>{const{source:c,target:o,unitId:l,subUnitId:u}=r,d=f.virtualizeDiscreteRanges([c,o]),[p,h]=d.ranges,{mapFunc:v}=d,g={row:p.startRow,col:p.startColumn},C=f.getAutoFillRepeatRange(p,h),L=[],T=[];return C.forEach(a=>{const k=a.repeatStartCell,x=a.relativeRange,N={startRow:g.row,startColumn:g.col,endColumn:g.col,endRow:g.row},D={startRow:k.row,startColumn:k.col,endColumn:k.col,endRow:k.row};s.Range.foreach(x,(V,A)=>{const q=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},N),{row:pe,col:Ee}=v(q.startRow,q.startColumn),re=this._hyperLinkModel.getHyperLinkByLocation(l,u,pe,Ee),de=s.Rectangle.getPositionRange({startRow:V,startColumn:A,endColumn:A,endRow:V},D),{row:he,col:ge}=v(de.startRow,de.startColumn),ie=s.Tools.generateRandomId(),F=this._hyperLinkModel.getHyperLinkByLocation(l,u,he,ge);F&&L.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:F.id}}),(f.APPLY_TYPE.COPY===i||f.APPLY_TYPE.SERIES===i)&&re&&(L.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...re,id:ie,row:he,column:ge}}}),T.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ie}})),F&&T.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:F}})})}),{undos:T,redos:L}},t={id:qe,onFillData:(r,i,c)=>c===f.APPLY_TYPE.COPY||c===f.APPLY_TYPE.ONLY_FORMAT||c===f.APPLY_TYPE.SERIES?n(r,c):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};we=$n([Pt(0,f.IAutoFillService),Pt(1,s.Inject(S.HyperLinkModel))],we);var Vn=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,Zn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Fn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Vn(n,t,i),i},Ye=(e,n)=>(t,r)=>n(t,r,e);let He=class extends s.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===tt.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],rangeTypes:[E.RangeProtectionPermissionEditPoint],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetSetCellValuePermission,E.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};He=Zn([Ye(0,s.Inject(s.LocaleService)),Ye(1,s.ICommandService),Ye(2,s.Inject(f.SheetPermissionInterceptorBaseController))],He);var Wn=Object.defineProperty,Kn=Object.getOwnPropertyDescriptor,Yn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Kn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Wn(n,t,i),i},z=(e,n)=>(t,r)=>n(t,r,e);let Ne=class extends s.Disposable{constructor(e,n,t,r,i,c,o,l,u,d){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=r,this._sheetPermissionInterceptorBaseController=i,this._commandService=c,this._editorBridgeService=o,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=d,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:r,col:i}=e,c=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET);if(!(c==null?void 0:c.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookViewPermission],worksheetTypes:[E.WorksheetViewPermission],rangeTypes:[E.RangeProtectionPermissionViewPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[E.WorkbookEditablePermission],worksheetTypes:[E.WorksheetEditPermission,E.WorksheetInsertHyperlinkPermission],rangeTypes:[E.RangeProtectionPermissionEditPoint]},[{startRow:r,startColumn:i,endRow:r,endColumn:i}]),d=this._permissionService.composePermission([new E.WorkbookCopyPermission(n).id,new E.WorksheetCopyPermission(n,t).id]).every(p=>p.value);return{viewPermission:l,editPermission:u,copyPermission:d}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(R.debounceTime(200)).subscribe(e=>{var N,D;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:r,col:i}=e,c=this._renderManagerService.getRenderById(n);if(!c)return;const o=this._univerInstanceService.getUnit(n,s.UniverInstanceType.UNIVER_SHEET),l=o==null?void 0:o.getSheetBySheetId(t);if(!l)return;if(!c.with(f.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING);return}const d=(N=c==null?void 0:c.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:N.skeleton,p=i,h=r;let v=h,g=p;d&&d.overflowCache.forValue((V,A,q)=>{s.Rectangle.contains(q,{startColumn:p,endColumn:p,startRow:h,endRow:h})&&(v=V,g=A)});const{viewPermission:C,editPermission:L,copyPermission:T}=this._getLinkPermission(e);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const a=l.getCellStyleOnly(v,g),k=o.getStyles().getStyleByCell(a),x=(D=k==null?void 0:k.tr)==null?void 0:D.a;if(!x&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:v,col:g,editPermission:L,copyPermission:T,customRange:e.customRange,customRangeRect:e.rect,type:I.VIEWING,unitId:n,subUnitId:t,showAll:!!x})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(R.switchMap(n=>this._editorBridgeService.visible$.pipe(R.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING);return}const{editorUnitId:r,unitId:i,sheetId:c,row:o,column:l}=t,u=this._renderManagerService.getRenderById(r);if(!u)return;const{editPermission:d,viewPermission:p,copyPermission:h}=this._getLinkPermission({unitId:i,subUnitId:c,row:o,col:l}),v=u.with(ne.DocEventManagerService);p&&(e==null||e.unsubscribe(),e=v.hoverCustomRanges$.pipe(R.debounceTime(200)).subscribe(g=>{var k,x;const C=g.find(N=>N.range.rangeType===s.CustomRangeType.HYPERLINK);if(!C){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=C.rects[C.rects.length-1];if(!((x=(k=this._renderManagerService.getRenderById(i))==null?void 0:k.with(f.SheetSkeletonManagerService).getWorksheetSkeleton(c))==null?void 0:x.skeleton)||!L)return;const a=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:i,subUnitId:c,row:o,col:l,customRange:C.range,customRangeRect:{left:L.left+a.left,top:L.top+a.top,bottom:L.bottom+a.top,right:L.right+a.left},editPermission:d,copyPermission:h,type:I.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.EDITING),this._sheetsHyperLinkPopupService.endEditing(I.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(I.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(I.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(R.switchMap(e=>{const n=e===s.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ne.DocEventManagerService).hoverCustomRanges$.pipe(R.debounceTime(200)):new R.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(r=>r.range.rangeType===s.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:r,sheetId:i,row:c,column:o}=t,{editPermission:l,viewPermission:u,copyPermission:d}=this._getLinkPermission({unitId:r,subUnitId:i,row:c,col:o});u&&this._sheetsHyperLinkPopupService.showPopup({type:I.ZEN_EDITOR,unitId:r,subUnitId:i,row:c,col:o,customRange:n.range,editPermission:l,copyPermission:d})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(I.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===s.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(I.EDITING)}))}_initCommandListener(){const e=[E.ClearSelectionContentCommand.id,E.ClearSelectionAllCommand.id,E.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};Ne=Yn([z(0,s.Inject(f.HoverManagerService)),z(1,s.Inject(exports.SheetsHyperLinkPopupService)),z(2,s.Inject(Ce.IRenderManagerService)),z(3,s.Inject(s.IPermissionService)),z(4,s.Inject(f.SheetPermissionInterceptorBaseController)),z(5,s.ICommandService),z(6,f.IEditorBridgeService),z(7,s.Inject(fe.DocSelectionManagerService)),z(8,s.IUniverInstanceService),z(9,b.IZenZoneService)],Ne);var Gn=Object.defineProperty,zn=Object.getOwnPropertyDescriptor,xt=(e,n,t,r)=>{for(var i=r>1?void 0:r?zn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Gn(n,t,i),i},Ge=(e,n)=>(t,r)=>n(t,r,e);let ze=class extends s.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(R.debounceTime(16)).subscribe(()=>{e()}))}};ze=xt([Ge(1,s.Inject(S.HyperLinkModel))],ze);let Ue=class extends s.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(E.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:r,col:i,unitId:c,subUnitId:o}=n,l=this._hyperLinkModel.getHyperLinkByLocation(c,o,r,i);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};Ue=xt([Ge(0,s.Inject(E.SheetInterceptorService)),Ge(1,s.Inject(S.HyperLinkModel))],Ue);const qn={[b.RibbonStartGroup.OTHERS]:{[ce.id]:{order:2,menuItemFactory:xn},[be(ce.id)]:{order:2,menuItemFactory:jn}},[b.ContextMenuPosition.MAIN_AREA]:{[b.ContextMenuGroup.OTHERS]:{order:1,[ce.id]:{order:0,menuItemFactory:Un},[be(ce.id)]:{order:0,menuItemFactory:Mn}}}};var Jn=Object.defineProperty,Xn=Object.getOwnPropertyDescriptor,Qn=(e,n,t,r)=>{for(var i=r>1?void 0:r?Xn(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&Jn(n,t,i),i},me=(e,n)=>(t,r)=>n(t,r,e);let Me=class extends s.Disposable{constructor(e,n,t,r,i){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=r,this._shortcutService=i,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[ke,ke.componentKey],[Te,Te.componentKey],[Xe,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[je,ye,Be,ce].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(qn)}_initShortCut(){this._shortcutService.registerShortcut(tt)}};Me=Qn([me(0,s.Inject(b.ComponentManager)),me(1,s.ICommandService),me(2,b.IMenuManagerService),me(3,s.Inject(s.Injector)),me(4,s.Inject(b.IShortcutService))],Me);var er=Object.defineProperty,tr=Object.getOwnPropertyDescriptor,nr=(e,n,t,r)=>{for(var i=r>1?void 0:r?tr(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&er(n,t,i),i},Tt=(e,n)=>(t,r)=>n(t,r,e);let xe=class extends s.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};xe=nr([Tt(0,s.Inject(S.SheetsHyperLinkParserService)),Tt(1,s.Inject(exports.SheetsHyperLinkResolverService))],xe);var jt=Object.defineProperty,rr=Object.getOwnPropertyDescriptor,ir=(e,n,t)=>n in e?jt(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,sr=(e,n,t,r)=>{for(var i=r>1?void 0:r?rr(n,t):n,c=e.length-1,o;c>=0;c--)(o=e[c])&&(i=(r?o(n,t,i):o(i))||i);return r&&i&&jt(n,t,i),i},kt=(e,n)=>(t,r)=>n(t,r,e),Bt=(e,n,t)=>ir(e,typeof n!="symbol"?n+"":n,t);exports.UniverSheetsHyperLinkUIPlugin=class extends s.Plugin{constructor(n=It,t,r){super(),this._config=n,this._injector=t,this._configService=r;const{menu:i,...c}=s.merge({},It,this._config);i&&this._configService.setConfig("menu",i,{merge:!0}),this._configService.setConfig(Ot,c)}onStarting(){[[exports.SheetsHyperLinkResolverService],[exports.SheetsHyperLinkPopupService],[Je],[Ue],[Ne],[Me],[we],[exports.SheetsHyperLinkCopyPasteController],[He],[xe]].forEach(t=>this._injector.add(t)),this._injector.get(Ue)}onReady(){this._injector.get(Ce.IRenderManagerService).registerRenderModule(s.UniverInstanceType.UNIVER_SHEET,[ze]),this._injector.get(we),this._injector.get(exports.SheetsHyperLinkCopyPasteController),this._injector.get(Me)}onRendered(){this._injector.get(He),this._injector.get(xe),this._injector.get(Ne)}};Bt(exports.UniverSheetsHyperLinkUIPlugin,"pluginName",qe);Bt(exports.UniverSheetsHyperLinkUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsHyperLinkUIPlugin=sr([s.DependentOn(S.UniverSheetsHyperLinkPlugin,ne.UniverDocsUIPlugin),kt(1,s.Inject(s.Injector)),kt(2,s.IConfigService)],exports.UniverSheetsHyperLinkUIPlugin);exports.CloseHyperLinkPopupOperation=ye;exports.InsertHyperLinkOperation=Be;exports.InsertLinkShortcut=tt;exports.OpenHyperLinkEditPanelOperation=je;exports.SheetsHyperLinkSidePanelService=Je;
package/lib/es/index.js CHANGED
@@ -881,7 +881,7 @@ const Vi = "univer-cell-link", Fi = "univer-cell-link-type", Wi = "univer-cell-l
881
881
  },
882
882
  children: [
883
883
  /* @__PURE__ */ m.jsx("div", { className: W.cellLinkType, children: qi[a.type] }),
884
- /* @__PURE__ */ m.jsx(Ae, { showIfEllipsis: !0, title: a.name, children: /* @__PURE__ */ m.jsx("span", { className: W.cellLinkUrl, children: a.name }) })
884
+ /* @__PURE__ */ m.jsx(Ae, { showIfEllipsis: !0, title: a.name, asChild: !0, children: /* @__PURE__ */ m.jsx("span", { className: W.cellLinkUrl, children: a.name }) })
885
885
  ]
886
886
  }
887
887
  ),
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(63 131 248 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*{scrollbar-color:initial;scrollbar-width:initial}@keyframes enter{0%{opacity:var(--tw-enter-opacity, 1);transform:translate3d(var(--tw-enter-translate-x, 0),var(--tw-enter-translate-y, 0),0) scale3d(var(--tw-enter-scale, 1),var(--tw-enter-scale, 1),var(--tw-enter-scale, 1)) rotate(var(--tw-enter-rotate, 0))}}@keyframes exit{to{opacity:var(--tw-exit-opacity, 1);transform:translate3d(var(--tw-exit-translate-x, 0),var(--tw-exit-translate-y, 0),0) scale3d(var(--tw-exit-scale, 1),var(--tw-exit-scale, 1),var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0))}}.univer-cell-link-edit{padding:16px;background-color:rgb(var(--color-white));width:296px;box-sizing:border-box;border-radius:var(--border-radius-xl);border:1px solid rgb(var(--grey-200));box-shadow:0 4px 10px -1px #1116281a}.univer-cell-link-edit-buttons{display:flex;flex-direction:row;justify-content:flex-end}.univer-cell-link{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:12px;box-shadow:var(--box-shadow-base);border-radius:8px;border:1px solid rgb(var(--grey-200));background:rgb(var(--color-white));max-width:328px;overflow:hidden;margin-bottom:var(--margin-xxs)}.univer-cell-link-type{height:20px;width:20px;font-size:16px;margin-right:8px;display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:rgb(var(--color-black))}.univer-cell-link-content{height:24px;display:flex;flex-direction:row;align-items:center;font-size:13px;line-height:20px;color:rgb(var(--blue-500));cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-cell-link-content-error{color:rgb(var(--grey-500))}.univer-cell-link-url{flex:1;overflow:hidden;text-overflow:ellipsis}.univer-cell-link-operations{display:flex;flex-direction:row;justify-content:center;align-items:center;height:24px;flex-basis:auto;flex-grow:0;flex-shrink:0}.univer-cell-link-operation{width:24px;height:24px;margin-left:8px;font-size:16px;display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;border-radius:4px}.univer-cell-link-operation-error{color:rgb(var(--grey-500))}.univer-cell-link-operation:hover{background:#ccc}
1
+ .univer-cell-link-edit{padding:16px;background-color:rgb(var(--color-white));width:296px;box-sizing:border-box;border-radius:var(--border-radius-xl);border:1px solid rgb(var(--grey-200));box-shadow:0 4px 10px -1px #1116281a}.univer-cell-link-edit-buttons{display:flex;flex-direction:row;justify-content:flex-end}.univer-cell-link{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:12px;box-shadow:var(--box-shadow-base);border-radius:8px;border:1px solid rgb(var(--grey-200));background:rgb(var(--color-white));max-width:328px;overflow:hidden;margin-bottom:var(--margin-xxs)}.univer-cell-link-type{height:20px;width:20px;font-size:16px;margin-right:8px;display:flex;align-items:center;justify-content:center;flex:0 0 auto;color:rgb(var(--color-black))}.univer-cell-link-content{height:24px;display:flex;flex-direction:row;align-items:center;font-size:13px;line-height:20px;color:rgb(var(--blue-500));cursor:pointer;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.univer-cell-link-content-error{color:rgb(var(--grey-500))}.univer-cell-link-url{flex:1;overflow:hidden;text-overflow:ellipsis}.univer-cell-link-operations{display:flex;flex-direction:row;justify-content:center;align-items:center;height:24px;flex-basis:auto;flex-grow:0;flex-shrink:0}.univer-cell-link-operation{width:24px;height:24px;margin-left:8px;font-size:16px;display:flex;flex-direction:row;justify-content:center;align-items:center;cursor:pointer;border-radius:4px}.univer-cell-link-operation-error{color:rgb(var(--grey-500))}.univer-cell-link-operation:hover{background:#ccc}
package/lib/umd/index.js CHANGED
@@ -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 st;function Qt(){if(st)return ve;st=1;var e=C,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,u,p){var d,h={},_=null,v=null;p!==void 0&&(_=""+p),u.key!==void 0&&(_=""+u.key),u.ref!==void 0&&(v=u.ref);for(d in u)i.call(u,d)&&!a.hasOwnProperty(d)&&(h[d]=u[d]);if(l&&l.defaultProps)for(d in u=l.defaultProps,u)h[d]===void 0&&(h[d]=u[d]);return{$$typeof:n,type:l,key:_,ref:v,props:h,_owner:r.current}}return ve.Fragment=t,ve.jsx=s,ve.jsxs=s,ve}var at;function qt(){return at||(at=1,Fe.exports=Qt()),Fe.exports}var m=qt();class Ze extends o.Disposable{constructor(){super(...arguments);K(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==S.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ct={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Le=()=>{var Lt;const[e,n]=C.useState(""),[t,i]=C.useState(!1),[r,a]=C.useState(""),[s,l]=C.useState(!0),[u,p]=C.useState(S.SheetHyperLinkType.URL),[d,h]=C.useState(""),_=o.useDependency(o.LocaleService),v=o.useDependency(X.IDefinedNamesService),E=o.useDependency(y.IEditorBridgeService),L=o.useDependency(o.IUniverInstanceService),O=o.useDependency(g.SheetsHyperLinkPopupService),c=b.useObservable(O.currentEditing$),D=o.useDependency(S.SheetsHyperLinkParserService),x=o.useDependency(g.SheetsHyperLinkResolverService),U=o.useDependency(o.ICommandService),N=o.useDependency(Ze),Z=C.useMemo(()=>N.getOptions(),[N]),F=o.useDependency(b.IZenZoneService),Q=o.useDependency(pe.IRenderManagerService),Ie=o.useDependency(y.IMarkSelectionService),Ae=o.useDependency(he.DocSelectionManagerService),ae=o.useDependency(o.IContextService),me=o.useDependency(o.ThemeService),fe=o.useDependency(he.DocSelectionManagerService),ye=C.useRef({}),ce=C.useMemo(()=>{if(!N.isBuiltInLinkType(u))return N.getCustomHyperLink(u)},[N,u]),[W,Zn]=C.useState(!1),[Ce,Xe]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Wn=($==null?void 0:$.getActiveSheet().getSheetId())||"",te=C.useCallback(I=>{a(I.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var I,k,T,M,j,z,Tt,Ot,Dt,kt,bt,wt,Nt,Mt,Ut,Ht,jt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:tt,col:nt}=c;let{label:q}=c;typeof q=="number"&&(q=`${q}`);let J;if(le)J={id:(I=le==null?void 0:le.rangeId)!=null?I:"",display:q!=null?q:"",payload:(T=(k=le==null?void 0:le.properties)==null?void 0:k.url)!=null?T:"",row:tt,column:nt};else if(c.type===f.VIEWING){const H=L.getUnit(c.unitId),ie=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ie==null?void 0:ie.getCellRaw(c.row,c.col),de=(z=(j=(M=B==null?void 0:B.p)==null?void 0:M.body)==null?void 0:j.customRanges)==null?void 0:z.find(Bt=>{var At;return Bt.rangeType===o.CustomRangeType.HYPERLINK&&((At=Bt.properties)==null?void 0:At.url)}),Ee=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((Ot=(Tt=B.p)==null?void 0:Tt.body)==null?void 0:Ot.dataStream)||o.Tools.isDefine(Ee))&&l(!1),J={id:"",display:"",payload:(kt=(Dt=de==null?void 0:de.properties)==null?void 0:Dt.url)!=null?kt:"",row:tt,column:nt}}else{const H=L.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),ie=Ae.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ie&&B?ie:null,Ee=de&&((wt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(bt=B==null?void 0:B.customRanges)!=null?bt:[]))==null?void 0:wt[0]);l(!1),J={id:"",display:q!=null?q:"",payload:(Mt=(Nt=Ee==null?void 0:Ee.properties)==null?void 0:Nt.url)!=null?Mt:"",row:tt,column:nt}}n(J.id);const xt=N.findCustomHyperLink(J);if(xt){const H=xt.convert(J);p(H.type),h(H.payload),te(H.display);return}te(J.display);const ne=D.parseHyperLink(J.payload);switch(p(ne.type===S.SheetHyperLinkType.INVALID?S.SheetHyperLinkType.RANGE:ne.type),ne.type){case S.SheetHyperLinkType.URL:{h(ne.url),ne.url===J.display&&(A.current=!0);break}case S.SheetHyperLinkType.RANGE:{const H=ne.searchObj,ie=H.gid&&(jt=(Ht=(Ut=L.getUnit(c.unitId))==null?void 0:Ut.getSheetBySheetId(H.gid))==null?void 0:Ht.getName())!=null?jt:"",B=X.serializeRangeWithSheet(ie,X.deserializeRangeWithSheet(H.range).range);h(B),B===J.display&&(A.current=!0);break}case S.SheetHyperLinkType.SHEET:{const H=ne.searchObj;h(H.gid);break}case S.SheetHyperLinkType.DEFINE_NAME:{const H=ne.searchObj;h(H.rangeid);break}default:h("");break}}},[c,x,N,Ae,L]),C.useEffect(()=>{let I=null;if(c&&!c.customRangeId&&c.type===f.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const k=L.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),T=k==null?void 0:k.getSheetBySheetId(c.subUnitId),M=T==null?void 0:T.getMergedCell(c.row,c.col),j=new o.ColorKit(me.getCurrentTheme().hyacinth500).toRgb();I=Ie.addShape({range:M!=null?M:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${j.r}, ${j.g}, ${j.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{I&&Ie.removeShape(I)}},[c,Ie,me,L]),C.useEffect(()=>{Xe(u===S.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const I=(c==null?void 0:c.type)===f.ZEN_EDITOR?Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):Q.getRenderById(E.getCurrentEditorId()),k=new o.DisposableCollection;if(I){const T=I.with(ee.DocSelectionRenderService);T.setReserveRangesStatus(!0),k.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),k.dispose()}},[c==null?void 0:c.type,E,Q]),C.useEffect(()=>(O.setIsKeepVisible(Ce),()=>{O.setIsKeepVisible(!1)}),[Ce,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ce)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ce,E]);const Kn=[{label:_.t("hyperLink.form.link"),value:S.SheetHyperLinkType.URL},{label:_.t("hyperLink.form.range"),value:S.SheetHyperLinkType.RANGE},{label:_.t("hyperLink.form.worksheet"),value:S.SheetHyperLinkType.SHEET},{label:_.t("hyperLink.form.definedName"),value:S.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Qe=$.getSheets().map(I=>({label:I.getName(),value:I.getSheetId()})).filter(I=>Yn.indexOf(I.value)===-1),qe=Object.values((Lt=v.getDefinedNameMap($.getUnitId()))!=null?Lt:{}).map(I=>({label:I.name,value:I.id})),Pt=(I,k)=>{if(I===S.SheetHyperLinkType.URL)return Wt(k);if(I===S.SheetHyperLinkType.RANGE){const T=X.deserializeRangeWithSheet(k),M=$.getSheetBySheetName(T.sheetName);if(M)return`#gid=${M.getSheetId()}&range=${X.serializeRange(T.range)}`}return`#${I}=${k}`},Gn=b.useEvent(I=>{var j;const T=I.split(",").map(X.deserializeRangeWithSheet)[0];if(!T||!o.isValidRange(T.range))return;T.sheetName||(T.sheetName=((j=$.getActiveSheet())==null?void 0:j.getName())||"");const M=X.serializeRangeToRefString(T);h(M),M&&(A.current||!r)&&(te(M),A.current=!0)}),et=async()=>{if(s&&!r||!d||u===S.SheetHyperLinkType.URL&&!Re(d)){Zn(!0);return}if(c)if(e){const I=c.type===f.ZEN_EDITOR||c.type===f.EDITING?S.UpdateRichHyperLinkCommand.id:S.UpdateHyperLinkCommand.id;await U.executeCommand(I,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:s?r:"",payload:Pt(u,d)},row:c.row,column:c.col,documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const I=c.type===f.ZEN_EDITOR||c.type===f.EDITING?S.AddRichHyperLinkCommand.id:S.AddHyperLinkCommand.id;await U.executeCommand(I,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:Pt(u,d),display:s?r:""},documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===f.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const I=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-I,0),endRow:c.row+I,startColumn:Math.max(c.col-I,0),endColumn:c.col+I}})}U.executeCommand(Se.id)},$n=I=>{var T;if(u!==S.SheetHyperLinkType.RANGE)return;const k=(T=ye.current)==null?void 0:T.handleOutClick;k&&k(I,()=>Xe(!1))};return c?m.jsxs("div",{className:ct.cellLinkEdit,style:{display:t?"none":"block"},onClick:$n,children:[s?m.jsx(w.FormLayout,{label:_.t("hyperLink.form.label"),error:W&&!r?_.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:r,onChange:I=>{te(I),A.current=!1},placeholder:_.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:I=>{I.keyCode===b.KeyCode.ENTER&&et()}})}):null,m.jsx(w.FormLayout,{label:_.t("hyperLink.form.type"),children:m.jsx(w.Select,{options:Kn,value:u,onChange:I=>{p(I),h("")}})}),u===S.SheetHyperLinkType.URL&&m.jsx(w.FormLayout,{error:W?d?Re(d)?"":_.t("hyperLink.form.linkError"):_.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:d,onChange:I=>{h(I),I&&(A.current||!r||r===d)&&(te(I),A.current=!0)},placeholder:_.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:I=>{I.keyCode===b.KeyCode.ENTER&&et()}})}),u===S.SheetHyperLinkType.RANGE&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.inputError"):"",children:m.jsx(Vt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Wn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ce,onFocus:()=>Xe(!0),actions:ye.current,onRangeSelectorDialogVisibleChange:async I=>{var k,T;if(I)c.type===f.ZEN_EDITOR&&(F.hide(),ae.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==f.VIEWING&&E.enableForceKeepVisible(),i(!0);else{if(await x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===f.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1);const M=(k=Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:k.with(ee.DocBackScrollRenderController),j=(T=fe.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];M&&j&&(M.scrollToRange(j),fe.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),i(!1)}}})}),u===S.SheetHyperLinkType.SHEET&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:Qe,value:d,onChange:I=>{var M,j;h(I);const k=(M=Qe.find(z=>z.value===I))==null?void 0:M.label,T=(j=Qe.find(z=>z.value===d))==null?void 0:j.label;k&&(A.current||!r||r===T)&&(te(k),A.current=!0)}})}),u===S.SheetHyperLinkType.DEFINE_NAME&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:qe,value:d,onChange:I=>{var M,j;h(I);const k=(M=qe.find(z=>z.value===I))==null?void 0:M.label,T=(j=qe.find(z=>z.value===d))==null?void 0:j.label;k&&(A.current||!r||r===T)&&(te(k),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&m.jsx(ce.Form,{linkId:e,payload:d,display:r,showError:W,setByPayload:A,setDisplay:I=>{te(I),A.current=!0},setPayload:h}),m.jsxs("div",{className:ct.cellLinkEditButtons,children:[m.jsx(w.Button,{onClick:()=>{c&&x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(Se.id)},children:_.t("hyperLink.form.cancel")}),m.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{et()},children:_.t("hyperLink.form.ok")})]})]}):null};Le.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)},en=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},re=C.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,a=e.extend,s=en(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),u=C.useRef("_".concat(rn()));return lt(t,"".concat(i),{defIds:t.defIds,idSuffix:u.current},V({ref:n,className:l},s),a)});function lt(e,n,t,i,r){return C.createElement(e.tag,V(V({key:n},tn(e,t,r)),i),(nn(e,t).children||[]).map(function(a,s){return lt(a,"".concat(n,"-").concat(e.tag,"-").concat(s),t,void 0,r)}))}function tn(e,n,t){var i=V({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function nn(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?V(V({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function rn(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";var on={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"}}]},Te=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"all-border-single",ref:n,icon:on}))});Te.displayName="AllBorderSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ut=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"copy-single",ref:n,icon:sn}))});ut.displayName="CopySingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},We=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"link-single",ref:n,icon:an}))});We.displayName="LinkSingle";var cn={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"}}]},dt=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"unlink-single",ref:n,icon:cn}))});dt.displayName="UnlinkSingle";var ln={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"}}]},pt=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"write-single",ref:n,icon:ln}))});pt.displayName="WriteSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ht=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"xlsx",ref:n,icon:un}))});ht.displayName="Xlsx";function vt(e){var n,t,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(t=vt(e[n]))&&(i&&(i+=" "),i+=t)}else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function gt(){for(var e,n,t=0,i="",r=arguments.length;t<r;t++)(e=arguments[t])&&(n=vt(e))&&(i&&(i+=" "),i+=n);return i}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},dn={[S.SheetHyperLinkType.URL]:m.jsx(We,{}),[S.SheetHyperLinkType.SHEET]:m.jsx(ht,{}),[S.SheetHyperLinkType.RANGE]:m.jsx(Te,{}),[S.SheetHyperLinkType.DEFINE_NAME]:m.jsx(Te,{}),[S.SheetHyperLinkType.INVALID]:m.jsx(Te,{})},St=e=>{var x,U;const n=o.useDependency(g.SheetsHyperLinkPopupService),t=o.useDependency(o.ICommandService),i=o.useDependency(b.IMessageService),r=o.useDependency(o.LocaleService),a=o.useDependency(g.SheetsHyperLinkResolverService),s=o.useDependency(y.IEditorBridgeService),l=o.useDependency(S.SheetsHyperLinkParserService),u=o.useDependency(b.IZenZoneService),{customRange:p,row:d,col:h,unitId:_,subUnitId:v,editPermission:E,copyPermission:L,type:O}=e;if(!((x=p==null?void 0:p.properties)!=null&&x.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),D=c.type===S.SheetHyperLinkType.INVALID;return m.jsxs("div",{className:Y.cellLink,onClick:()=>n.hideCurrentPopup(),children:[m.jsxs("div",{className:gt(Y.cellLinkContent,{[Y.cellLinkContentError]:D}),onClick:()=>{u.visible||D||a.navigate(c)},children:[m.jsx("div",{className:Y.cellLinkType,children:dn[c.type]}),m.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,children:m.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),m.jsxs("div",{className:Y.cellLinkOperations,children:[L&&m.jsx("div",{className:gt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:D}),onClick:()=>{if(!D){if(c.type!==S.SheetHyperLinkType.URL){const N=new URL(window.location.href);N.hash=c.url.slice(1),navigator.clipboard.writeText(N.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(ut,{})})}),E&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{t.executeCommand(De.id,{unitId:_,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(pt,{})})}),m.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const N=O===f.EDITING||O===f.ZEN_EDITOR?S.CancelRichHyperLinkCommand.id:S.CancelHyperLinkCommand.id;t.syncExecuteCommand(N,{unitId:_,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:s.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(dt,{})})})]})]})]})},Oe=()=>{var r,a;const e=o.useDependency(g.SheetsHyperLinkPopupService),[n,t]=C.useState(null),i=o.useDependency(o.IUniverInstanceService);if(C.useEffect(()=>{t(e.currentPopup);const s=e.currentPopup$.subscribe(l=>{t(l)});return()=>{s.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const s=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?m.jsx("div",{children:p.map(d=>m.jsx(St,{...n,customRange:d},d.rangeId))}):null}return m.jsx(St,{...n})};Oe.componentKey="univer.sheet.cell-link-popup";var pn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,vn=(e,n,t,i)=>{for(var r=i>1?void 0:i?hn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&pn(n,t,r),r},oe=(e,n)=>(t,i)=>n(t,i,e);const _t=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,a,s,l,u){super();K(this,"_currentPopup",null);K(this,"_currentPopup$",new P.Subject);K(this,"currentPopup$",this._currentPopup$.asObservable());K(this,"_currentEditingPopup",null);K(this,"_currentEditing$",new P.BehaviorSubject(null));K(this,"currentEditing$",this._currentEditing$.asObservable());K(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=s,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&_t(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==f.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&_t(t,i))return;const{unitId:r,subUnitId:a,row:s,col:l,customRangeRect:u,customRange:p}=t;let d;const h={componentKey:Oe.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===f.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(t.type===f.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,t)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:s,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:p,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,a;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,s;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(s=(a=u.customRanges)==null?void 0:a.filter(_=>_.rangeType===o.CustomRangeType.HYPERLINK))!=null?s:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(_=>{d=Math.min(d,_.startIndex),h=Math.max(h,_.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:o.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Le.componentKey,direction:"vertical",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var s,l,u,p,d;const{unitId:i,subUnitId:r,type:a}=t;if(a===f.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!h)return;const _=this._textSelectionManagerService.getActiveTextRange();if(!_)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(_,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(s=h.getBody())==null?void 0:s.dataStream.slice(_.startOffset,_.endOffset);this._currentEditing$.next({...t,label:v})}else if(a===f.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const _=this._injector.get(pe.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!_)return;const v=ee.calcDocRangePositions(h,_);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const h=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),_=h==null?void 0:h.getSheetBySheetId(r),v=_==null?void 0:_.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:v!=null&&v.p?o.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(t){var l,u,p,d,h,_;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let a,s;if(t.type===f.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===t.customRangeId),s=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!s)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===f.EDITING){const v=y.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,s=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,i,r)}else{const v=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(t.row,t.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,D=y.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!D||!((_=D.rects)!=null&&_.length))return;a=D.customRange,s=D.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(D.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:a,label:s})}endEditing(t){var r;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=vn([oe(0,o.Inject(y.SheetCanvasPopManagerService)),oe(1,o.Inject(o.Injector)),oe(2,o.IUniverInstanceService),oe(3,y.IEditorBridgeService),oe(4,o.Inject(he.DocSelectionManagerService)),oe(5,o.Inject(ee.DocCanvasPopManagerService)),oe(6,b.IZenZoneService)],g.SheetsHyperLinkPopupService);var ge=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(ge||{});const gn=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Ke=(e,n,t,i)=>{var l,u;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si)return 1;const a=e.has(it.SheetDataValidationModel)?e.get(it.SheetDataValidationModel):null,s=a==null?void 0:a.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return s&&gn.has(s.type)?!0:(u=(l=r==null?void 0:r.p)==null?void 0:l.drawingsOrder)!=null&&u.length?2:0},Sn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(R.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,a=i[0].range.startColumn;return Ke(e,t,r,a)===1},_n=e=>{const n=e.get(he.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(s=>s.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},De={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},Se={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var h;const n=e.get(o.IUniverInstanceService),t=R.getSheetCommandTarget(n),i=e.get(y.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),s=e.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!s)return!1;const l=s.range.startRow,u=s.range.startColumn,p=i.isVisible(),d=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(De.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:d?f.ZEN_EDITOR:p.visible?f.EDITING:f.VIEWING})}},se={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(Sn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Se.id):n.executeCommand(ke.id)}},Ye=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(pe.IRenderManagerService).getRenderById(n))==null?void 0:r.with(ee.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(P.map(()=>{const s=e.get(y.IEditorBridgeService).getEditCellState();if(!s)return!0;const l=R.getSheetCommandTarget(t,{unitId:s.unitId,subUnitId:s.sheetId});return!(l!=null&&l.worksheet)||Ke(e,l.worksheet,s.row,s.column)===1?!0:_n(e)})):P.of(!0)},It=e=>{const n=y.getCurrentRangeDisable$(e,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),t=e.get(o.IUniverInstanceService),i=e.get(R.SheetsSelectionsService),r=e.has(y.IEditorBridgeService)?e.get(y.IEditorBridgeService):null,a=t.focused$.pipe(P.filter(s=>!!s),P.map(s=>t.getUnit(s,o.UniverInstanceType.UNIVER_SHEET)),P.filter(s=>!!s),P.switchMap(s=>s.activeSheet$),P.switchMap(s=>i.selectionMoveEnd$.pipe(P.map(l=>s&&{selections:l,sheet:s}))),P.map(s=>{if(!s)return ge.DISABLED_BY_CELL;const{selections:l,sheet:u}=s;if(!l.length)return ge.DISABLED_BY_CELL;const p=l[0].range.startRow,d=l[0].range.startColumn;return Ke(e,u,p,d)}),P.switchMap(s=>{if(s===ge.DISABLED_BY_CELL)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=e.get(o.IContextService).subscribeContextValue$(o.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ye(e,p):P.of(s===ge.ALLOW_ON_EDITING)))}));return n.pipe(P.distinctUntilChanged(),P.switchMap(s=>a.pipe(P.map(l=>s||l))))},be={commandId:ke.id,type:b.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},we=e=>`${e}-zen-editor`,In=e=>({...be,id:be.commandId,hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:It(e)}),mn=e=>({...be,id:we(be.commandId),hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ye(e)}),Ne={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:b.MenuItemType.BUTTON,icon:"LinkSingle"},fn=e=>({...Ne,id:Ne.commandId,hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:It(e)}),yn=e=>({...Ne,id:we(Ne.commandId),hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ye(e)}),Ge={id:se.id,binding:b.KeyCode.K|b.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(e,n,t,i)=>{for(var r=i>1?void 0:i?En(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Cn(n,t,r),r},mt=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:a,target:s,unitId:l,subUnitId:u}=i,p=y.virtualizeDiscreteRanges([a,s]),[d,h]=p.ranges,{mapFunc:_}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const D=c.repeatStartCell,x=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},N={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};o.Range.foreach(x,(Z,F)=>{const Q=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Ie,col:Ae}=_(Q.startRow,Q.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Ie,Ae),me=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},N),{row:fe,col:ye}=_(me.startRow,me.startColumn),ce=o.Tools.generateRandomId(),W=this._hyperLinkModel.getHyperLinkByLocation(l,u,fe,ye);W&&L.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:W.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:fe,column:ye}}}),O.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),W&&O.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:W}})})}),{undos:O,redos:L}},t={id:Ve,onFillData:(i,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?n(i,a):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};Me=Rn([mt(0,y.IAutoFillService),mt(1,o.Inject(S.HyperLinkModel))],Me);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ln(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Pn(n,t,r),r},$e=(e,n)=>(t,i)=>n(t,i,e);let Ue=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Ge.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ue=Tn([$e(0,o.Inject(o.LocaleService)),$e(1,o.ICommandService),$e(2,o.Inject(y.SheetPermissionInterceptorBaseController))],Ue);var On=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,kn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Dn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&On(n,t,r),r},G=(e,n)=>(t,i)=>n(t,i,e);let He=class extends o.Disposable{constructor(e,n,t,i,r,a,s,l,u,p){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=s,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(n).id,new R.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(e=>{var U,N;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,a=this._renderManagerService.getRenderById(n);if(!a)return;const s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(t);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:U.skeleton,d=r,h=i;let _=h,v=d;p&&p.overflowCache.forValue((Z,F,Q)=>{o.Rectangle.contains(Q,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(_=Z,v=F)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(e);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(_,v),D=s.getStyles().getStyleByCell(c),x=(N=D==null?void 0:D.tr)==null?void 0:N.a;if(!x&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:v,editPermission:L,copyPermission:O,customRange:e.customRange,customRangeRect:e.rect,type:f.VIEWING,unitId:n,subUnitId:t,showAll:!!x})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(n=>this._editorBridgeService.visible$.pipe(P.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:a,row:s,column:l}=t,u=this._renderManagerService.getRenderById(i);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:s,col:l}),_=u.with(ee.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var D,x;const E=v.find(U=>U.range.rangeType===o.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((x=(D=this._renderManagerService.getRenderById(r))==null?void 0:D.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:x.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:s,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:f.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(f.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ee.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:a,column:s}=t,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:i,subUnitId:r,row:a,col:s});u&&this._sheetsHyperLinkPopupService.showPopup({type:f.ZEN_EDITOR,unitId:i,subUnitId:r,row:a,col:s,customRange:n.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(f.EDITING)}))}_initCommandListener(){const e=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};He=kn([G(0,o.Inject(y.HoverManagerService)),G(1,o.Inject(g.SheetsHyperLinkPopupService)),G(2,o.Inject(pe.IRenderManagerService)),G(3,o.Inject(o.IPermissionService)),G(4,o.Inject(y.SheetPermissionInterceptorBaseController)),G(5,o.ICommandService),G(6,y.IEditorBridgeService),G(7,o.Inject(he.DocSelectionManagerService)),G(8,o.IUniverInstanceService),G(9,b.IZenZoneService)],He);var bn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,ft=(e,n,t,i)=>{for(var r=i>1?void 0:i?wn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&bn(n,t,r),r},ze=(e,n)=>(t,i)=>n(t,i,e);let Je=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{e()}))}};Je=ft([ze(1,o.Inject(S.HyperLinkModel))],Je);let je=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:a,subUnitId:s}=n,l=this._hyperLinkModel.getHyperLinkByLocation(a,s,i,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};je=ft([ze(0,o.Inject(R.SheetInterceptorService)),ze(1,o.Inject(S.HyperLinkModel))],je);const Nn={[b.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:fn},[we(se.id)]:{order:2,menuItemFactory:yn}},[b.ContextMenuPosition.MAIN_AREA]:{[b.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:In},[we(se.id)]:{order:0,menuItemFactory:mn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Un(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Mn(n,t,r),r},_e=(e,n)=>(t,i)=>n(t,i,e);let xe=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Oe,Oe.componentKey],[Le,Le.componentKey],[We,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[De,Se,ke,se].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(Ge)}};xe=Hn([_e(0,o.Inject(b.ComponentManager)),_e(1,o.ICommandService),_e(2,b.IMenuManagerService),_e(3,o.Inject(o.Injector)),_e(4,o.Inject(b.IShortcutService))],xe);var jn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Bn=(e,n,t,i)=>{for(var r=i>1?void 0:i?xn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&jn(n,t,r),r},yt=(e,n)=>(t,i)=>n(t,i,e);let Be=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};Be=Bn([yt(0,o.Inject(S.SheetsHyperLinkParserService)),yt(1,o.Inject(g.SheetsHyperLinkResolverService))],Be);var Ct=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(e,n,t)=>n in e?Ct(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Fn=(e,n,t,i)=>{for(var r=i>1?void 0:i?An(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Ct(n,t,r),r},Et=(e,n)=>(t,i)=>n(t,i,e),Rt=(e,n,t)=>Vn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=ot,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...a}=o.merge({},ot,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,a)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Ze],[je],[He],[xe],[Me],[g.SheetsHyperLinkCopyPasteController],[Ue],[Be]].forEach(t=>this._injector.add(t)),this._injector.get(je)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Je]),this._injector.get(Me),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Ue),this._injector.get(Be),this._injector.get(He)}},Rt(g.UniverSheetsHyperLinkUIPlugin,"pluginName",Ve),Rt(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Fn([o.DependentOn(S.UniverSheetsHyperLinkPlugin,ee.UniverDocsUIPlugin),Et(1,o.Inject(o.Injector)),Et(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=Se,g.InsertHyperLinkOperation=ke,g.InsertLinkShortcut=Ge,g.OpenHyperLinkEditPanelOperation=De,g.SheetsHyperLinkSidePanelService=Ze,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
9
+ */var st;function Qt(){if(st)return ve;st=1;var e=C,n=Symbol.for("react.element"),t=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,r=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function s(l,u,p){var d,h={},_=null,v=null;p!==void 0&&(_=""+p),u.key!==void 0&&(_=""+u.key),u.ref!==void 0&&(v=u.ref);for(d in u)i.call(u,d)&&!a.hasOwnProperty(d)&&(h[d]=u[d]);if(l&&l.defaultProps)for(d in u=l.defaultProps,u)h[d]===void 0&&(h[d]=u[d]);return{$$typeof:n,type:l,key:_,ref:v,props:h,_owner:r.current}}return ve.Fragment=t,ve.jsx=s,ve.jsxs=s,ve}var at;function qt(){return at||(at=1,Fe.exports=Qt()),Fe.exports}var m=qt();class Ze extends o.Disposable{constructor(){super(...arguments);K(this,"_customHyperLinks",new Map)}isBuiltInLinkType(t){return t!==S.SheetHyperLinkType.URL}getOptions(){return Array.from(this._customHyperLinks.values()).map(({option:t})=>t)}findCustomHyperLink(t){return Array.from(this._customHyperLinks.values()).find(r=>r.match(t))}registerCustomHyperLink(t){this._customHyperLinks.set(t.type,t)}getCustomHyperLink(t){return this._customHyperLinks.get(t)}removeCustomHyperLink(t){const{_customHyperLinks:i}=this;i.delete(t)}dispose(){super.dispose(),this._customHyperLinks.clear()}}const ct={cellLinkEdit:"univer-cell-link-edit",cellLinkEditButtons:"univer-cell-link-edit-buttons"},Le=()=>{var Lt;const[e,n]=C.useState(""),[t,i]=C.useState(!1),[r,a]=C.useState(""),[s,l]=C.useState(!0),[u,p]=C.useState(S.SheetHyperLinkType.URL),[d,h]=C.useState(""),_=o.useDependency(o.LocaleService),v=o.useDependency(X.IDefinedNamesService),E=o.useDependency(y.IEditorBridgeService),L=o.useDependency(o.IUniverInstanceService),O=o.useDependency(g.SheetsHyperLinkPopupService),c=b.useObservable(O.currentEditing$),D=o.useDependency(S.SheetsHyperLinkParserService),x=o.useDependency(g.SheetsHyperLinkResolverService),U=o.useDependency(o.ICommandService),N=o.useDependency(Ze),Z=C.useMemo(()=>N.getOptions(),[N]),F=o.useDependency(b.IZenZoneService),Q=o.useDependency(pe.IRenderManagerService),Ie=o.useDependency(y.IMarkSelectionService),Ae=o.useDependency(he.DocSelectionManagerService),ae=o.useDependency(o.IContextService),me=o.useDependency(o.ThemeService),fe=o.useDependency(he.DocSelectionManagerService),ye=C.useRef({}),ce=C.useMemo(()=>{if(!N.isBuiltInLinkType(u))return N.getCustomHyperLink(u)},[N,u]),[W,Zn]=C.useState(!1),[Ce,Xe]=C.useState(!1),A=C.useRef(!1),$=L.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET),Wn=($==null?void 0:$.getActiveSheet().getSheetId())||"",te=C.useCallback(I=>{a(I.replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_START,"").replaceAll(o.DataStreamTreeTokenType.CUSTOM_RANGE_END,""))},[a]);C.useEffect(()=>{var I,k,T,M,j,z,Tt,Ot,Dt,kt,bt,wt,Nt,Mt,Ut,Ht,jt;if((c==null?void 0:c.row)!==void 0&&c.col!==void 0){const{customRange:le,row:tt,col:nt}=c;let{label:q}=c;typeof q=="number"&&(q=`${q}`);let J;if(le)J={id:(I=le==null?void 0:le.rangeId)!=null?I:"",display:q!=null?q:"",payload:(T=(k=le==null?void 0:le.properties)==null?void 0:k.url)!=null?T:"",row:tt,column:nt};else if(c.type===f.VIEWING){const H=L.getUnit(c.unitId),ie=H==null?void 0:H.getSheetBySheetId(c.subUnitId),B=ie==null?void 0:ie.getCellRaw(c.row,c.col),de=(z=(j=(M=B==null?void 0:B.p)==null?void 0:M.body)==null?void 0:j.customRanges)==null?void 0:z.find(Bt=>{var At;return Bt.rangeType===o.CustomRangeType.HYPERLINK&&((At=Bt.properties)==null?void 0:At.url)}),Ee=B==null?void 0:B.v;B&&(!o.BuildTextUtils.transform.isEmptyDocument((Ot=(Tt=B.p)==null?void 0:Tt.body)==null?void 0:Ot.dataStream)||o.Tools.isDefine(Ee))&&l(!1),J={id:"",display:"",payload:(kt=(Dt=de==null?void 0:de.properties)==null?void 0:Dt.url)!=null?kt:"",row:tt,column:nt}}else{const H=L.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC),ie=Ae.getActiveTextRange(),B=H==null?void 0:H.getBody(),de=ie&&B?ie:null,Ee=de&&((wt=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(de,(bt=B==null?void 0:B.customRanges)!=null?bt:[]))==null?void 0:wt[0]);l(!1),J={id:"",display:q!=null?q:"",payload:(Mt=(Nt=Ee==null?void 0:Ee.properties)==null?void 0:Nt.url)!=null?Mt:"",row:tt,column:nt}}n(J.id);const xt=N.findCustomHyperLink(J);if(xt){const H=xt.convert(J);p(H.type),h(H.payload),te(H.display);return}te(J.display);const ne=D.parseHyperLink(J.payload);switch(p(ne.type===S.SheetHyperLinkType.INVALID?S.SheetHyperLinkType.RANGE:ne.type),ne.type){case S.SheetHyperLinkType.URL:{h(ne.url),ne.url===J.display&&(A.current=!0);break}case S.SheetHyperLinkType.RANGE:{const H=ne.searchObj,ie=H.gid&&(jt=(Ht=(Ut=L.getUnit(c.unitId))==null?void 0:Ut.getSheetBySheetId(H.gid))==null?void 0:Ht.getName())!=null?jt:"",B=X.serializeRangeWithSheet(ie,X.deserializeRangeWithSheet(H.range).range);h(B),B===J.display&&(A.current=!0);break}case S.SheetHyperLinkType.SHEET:{const H=ne.searchObj;h(H.gid);break}case S.SheetHyperLinkType.DEFINE_NAME:{const H=ne.searchObj;h(H.rangeid);break}default:h("");break}}},[c,x,N,Ae,L]),C.useEffect(()=>{let I=null;if(c&&!c.customRangeId&&c.type===f.VIEWING&&o.Tools.isDefine(c.row)&&o.Tools.isDefine(c.col)){const k=L.getUnit(c.unitId,o.UniverInstanceType.UNIVER_SHEET),T=k==null?void 0:k.getSheetBySheetId(c.subUnitId),M=T==null?void 0:T.getMergedCell(c.row,c.col),j=new o.ColorKit(me.getCurrentTheme().hyacinth500).toRgb();I=Ie.addShape({range:M!=null?M:{startColumn:c.col,endColumn:c.col,startRow:c.row,endRow:c.row},style:{fill:`rgb(${j.r}, ${j.g}, ${j.b}, 0.12)`,strokeWidth:1,stroke:"#FFBD37",widgets:{}},primary:null},[],-1)}return()=>{I&&Ie.removeShape(I)}},[c,Ie,me,L]),C.useEffect(()=>{Xe(u===S.SheetHyperLinkType.RANGE)},[u]),C.useEffect(()=>{const I=(c==null?void 0:c.type)===f.ZEN_EDITOR?Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY):Q.getRenderById(E.getCurrentEditorId()),k=new o.DisposableCollection;if(I){const T=I.with(ee.DocSelectionRenderService);T.setReserveRangesStatus(!0),k.add(()=>{T.setReserveRangesStatus(!1)})}return()=>{E.disableForceKeepVisible(),k.dispose()}},[c==null?void 0:c.type,E,Q]),C.useEffect(()=>(O.setIsKeepVisible(Ce),()=>{O.setIsKeepVisible(!1)}),[Ce,O]),C.useEffect(()=>()=>{F.temporaryHidden&&(F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1))},[ae,F]),C.useEffect(()=>{if(Ce)return E.enableForceKeepVisible(),()=>{E.disableForceKeepVisible()}},[Ce,E]);const Kn=[{label:_.t("hyperLink.form.link"),value:S.SheetHyperLinkType.URL},{label:_.t("hyperLink.form.range"),value:S.SheetHyperLinkType.RANGE},{label:_.t("hyperLink.form.worksheet"),value:S.SheetHyperLinkType.SHEET},{label:_.t("hyperLink.form.definedName"),value:S.SheetHyperLinkType.DEFINE_NAME},...Z];if(!$)return;const Yn=$.getHiddenWorksheets(),Qe=$.getSheets().map(I=>({label:I.getName(),value:I.getSheetId()})).filter(I=>Yn.indexOf(I.value)===-1),qe=Object.values((Lt=v.getDefinedNameMap($.getUnitId()))!=null?Lt:{}).map(I=>({label:I.name,value:I.id})),Pt=(I,k)=>{if(I===S.SheetHyperLinkType.URL)return Wt(k);if(I===S.SheetHyperLinkType.RANGE){const T=X.deserializeRangeWithSheet(k),M=$.getSheetBySheetName(T.sheetName);if(M)return`#gid=${M.getSheetId()}&range=${X.serializeRange(T.range)}`}return`#${I}=${k}`},Gn=b.useEvent(I=>{var j;const T=I.split(",").map(X.deserializeRangeWithSheet)[0];if(!T||!o.isValidRange(T.range))return;T.sheetName||(T.sheetName=((j=$.getActiveSheet())==null?void 0:j.getName())||"");const M=X.serializeRangeToRefString(T);h(M),M&&(A.current||!r)&&(te(M),A.current=!0)}),et=async()=>{if(s&&!r||!d||u===S.SheetHyperLinkType.URL&&!Re(d)){Zn(!0);return}if(c)if(e){const I=c.type===f.ZEN_EDITOR||c.type===f.EDITING?S.UpdateRichHyperLinkCommand.id:S.UpdateHyperLinkCommand.id;await U.executeCommand(I,{id:e,unitId:c.unitId,subUnitId:c.subUnitId,payload:{display:s?r:"",payload:Pt(u,d)},row:c.row,column:c.col,documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}else{const I=c.type===f.ZEN_EDITOR||c.type===f.EDITING?S.AddRichHyperLinkCommand.id:S.AddHyperLinkCommand.id;await U.executeCommand(I,{unitId:c.unitId,subUnitId:c.subUnitId,link:{id:o.generateRandomId(),row:c.row,column:c.col,payload:Pt(u,d),display:s?r:""},documentId:c.type===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:E.getCurrentEditorId()})}if((c==null?void 0:c.type)===f.VIEWING){await U.executeCommand(R.SetWorksheetActiveOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId});const I=1;await U.executeCommand(y.ScrollToRangeOperation.id,{range:{startRow:Math.max(c.row-I,0),endRow:c.row+I,startColumn:Math.max(c.col-I,0),endColumn:c.col+I}})}U.executeCommand(Se.id)},$n=I=>{var T;if(u!==S.SheetHyperLinkType.RANGE)return;const k=(T=ye.current)==null?void 0:T.handleOutClick;k&&k(I,()=>Xe(!1))};return c?m.jsxs("div",{className:ct.cellLinkEdit,style:{display:t?"none":"block"},onClick:$n,children:[s?m.jsx(w.FormLayout,{label:_.t("hyperLink.form.label"),error:W&&!r?_.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:r,onChange:I=>{te(I),A.current=!1},placeholder:_.t("hyperLink.form.labelPlaceholder"),autoFocus:!0,onKeyDown:I=>{I.keyCode===b.KeyCode.ENTER&&et()}})}):null,m.jsx(w.FormLayout,{label:_.t("hyperLink.form.type"),children:m.jsx(w.Select,{options:Kn,value:u,onChange:I=>{p(I),h("")}})}),u===S.SheetHyperLinkType.URL&&m.jsx(w.FormLayout,{error:W?d?Re(d)?"":_.t("hyperLink.form.linkError"):_.t("hyperLink.form.inputError"):"",children:m.jsx(w.Input,{value:d,onChange:I=>{h(I),I&&(A.current||!r||r===d)&&(te(I),A.current=!0)},placeholder:_.t("hyperLink.form.linkPlaceholder"),autoFocus:!0,onKeyDown:I=>{I.keyCode===b.KeyCode.ENTER&&et()}})}),u===S.SheetHyperLinkType.RANGE&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.inputError"):"",children:m.jsx(Vt.RangeSelector,{unitId:$.getUnitId(),subUnitId:Wn,isOnlyOneRange:!0,isSupportAcrossSheet:!0,initValue:d,onChange:Gn,isFocus:Ce,onFocus:()=>Xe(!0),actions:ye.current,onRangeSelectorDialogVisibleChange:async I=>{var k,T;if(I)c.type===f.ZEN_EDITOR&&(F.hide(),ae.setContextValue(o.FOCUSING_SHEET,!0)),c.type!==f.VIEWING&&E.enableForceKeepVisible(),i(!0);else{if(await x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),c.type===f.ZEN_EDITOR){await U.executeCommand(R.SetSelectionsOperation.id,{unitId:c.unitId,subUnitId:c.subUnitId,selections:[{range:{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col}}]}),F.show(),ae.setContextValue(o.FOCUSING_SHEET,!1);const M=(k=Q.getRenderById(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY))==null?void 0:k.with(ee.DocBackScrollRenderController),j=(T=fe.getTextRanges({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))==null?void 0:T[0];M&&j&&(M.scrollToRange(j),fe.refreshSelection({unitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_ZEN_EDITOR_UNIT_ID_KEY}))}E.disableForceKeepVisible(),i(!1)}}})}),u===S.SheetHyperLinkType.SHEET&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:Qe,value:d,onChange:I=>{var M,j;h(I);const k=(M=Qe.find(z=>z.value===I))==null?void 0:M.label,T=(j=Qe.find(z=>z.value===d))==null?void 0:j.label;k&&(A.current||!r||r===T)&&(te(k),A.current=!0)}})}),u===S.SheetHyperLinkType.DEFINE_NAME&&m.jsx(w.FormLayout,{error:W&&!d?_.t("hyperLink.form.selectError"):"",children:m.jsx(w.Select,{options:qe,value:d,onChange:I=>{var M,j;h(I);const k=(M=qe.find(z=>z.value===I))==null?void 0:M.label,T=(j=qe.find(z=>z.value===d))==null?void 0:j.label;k&&(A.current||!r||r===T)&&(te(k),A.current=!0)}})}),(ce==null?void 0:ce.Form)&&m.jsx(ce.Form,{linkId:e,payload:d,display:r,showError:W,setByPayload:A,setDisplay:I=>{te(I),A.current=!0},setPayload:h}),m.jsxs("div",{className:ct.cellLinkEditButtons,children:[m.jsx(w.Button,{onClick:()=>{c&&x.navigateToRange(c.unitId,c.subUnitId,{startRow:c.row,endRow:c.row,startColumn:c.col,endColumn:c.col},!0),U.executeCommand(Se.id)},children:_.t("hyperLink.form.cancel")}),m.jsx(w.Button,{type:"primary",style:{marginLeft:8},onClick:async()=>{et()},children:_.t("hyperLink.form.ok")})]})]}):null};Le.componentKey="univer.sheet.cell-link-edit";var V=function(){return V=Object.assign||function(e){for(var n,t=1,i=arguments.length;t<i;t++){n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},V.apply(this,arguments)},en=function(e,n){var t={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&n.indexOf(i)<0&&(t[i]=e[i]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)n.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(t[i[r]]=e[i[r]]);return t},re=C.forwardRef(function(e,n){var t=e.icon,i=e.id,r=e.className,a=e.extend,s=en(e,["icon","id","className","extend"]),l="univerjs-icon univerjs-icon-".concat(i," ").concat(r||"").trim(),u=C.useRef("_".concat(rn()));return lt(t,"".concat(i),{defIds:t.defIds,idSuffix:u.current},V({ref:n,className:l},s),a)});function lt(e,n,t,i,r){return C.createElement(e.tag,V(V({key:n},tn(e,t,r)),i),(nn(e,t).children||[]).map(function(a,s){return lt(a,"".concat(n,"-").concat(e.tag,"-").concat(s),t,void 0,r)}))}function tn(e,n,t){var i=V({},e.attrs);t!=null&&t.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=t.colorChannel1);var r=n.defIds;return!r||r.length===0||(e.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+n.idSuffix),Object.entries(i).forEach(function(a){var s=a[0],l=a[1];typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,"url(#$1".concat(n.idSuffix,")")))})),i}function nn(e,n){var t,i=n.defIds;return!i||i.length===0?e:e.tag==="defs"&&(!((t=e.children)===null||t===void 0)&&t.length)?V(V({},e),{children:e.children.map(function(r){return typeof r.attrs.id=="string"&&i&&i.indexOf(r.attrs.id)>-1?V(V({},r),{attrs:V(V({},r.attrs),{id:r.attrs.id+n.idSuffix})}):r})}):e}function rn(){return Math.random().toString(36).substring(2,8)}re.displayName="UniverIcon";var on={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"}}]},Te=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"all-border-single",ref:n,icon:on}))});Te.displayName="AllBorderSingle";var sn={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.1302 12.4251C4.25802 13.7417 5.36779 14.7708 6.71792 14.7708H11.7179C13.1539 14.7708 14.3179 13.6067 14.3179 12.1708V6.1708C14.3179 4.78586 13.2351 3.65383 11.8698 3.57517C11.742 2.25858 10.6323 1.22949 9.28213 1.22949H4.28213C2.84619 1.22949 1.68213 2.39355 1.68213 3.82949V9.82949C1.68213 11.2144 2.76497 12.3465 4.1302 12.4251ZM10.6583 3.5708H6.71792C5.28198 3.5708 4.11792 4.73486 4.11792 6.1708V11.22C3.4221 11.1387 2.88213 10.5471 2.88213 9.82949V3.82949C2.88213 3.05629 3.50893 2.42949 4.28213 2.42949H9.28213C9.96695 2.42949 10.5369 2.92119 10.6583 3.5708ZM13.1179 6.1708C13.1179 5.3976 12.4911 4.7708 11.7179 4.7708H6.71792C5.94472 4.7708 5.31792 5.3976 5.31792 6.1708V12.1708C5.31792 12.944 5.94472 13.5708 6.71792 13.5708H11.7179C12.4911 13.5708 13.1179 12.944 13.1179 12.1708V6.1708Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ut=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"copy-single",ref:n,icon:sn}))});ut.displayName="CopySingle";var an={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.8816 1.97978C11.0177 0.843607 12.862 0.884962 14.0004 2.02342C15.1389 3.16188 15.1803 5.00612 14.0441 6.14228L11.399 8.78737C11.1608 9.02559 10.7746 9.02559 10.5363 8.78737C10.2981 8.54915 10.2981 8.16292 10.5363 7.9247L13.1814 5.2796C13.8195 4.64155 13.8217 3.57006 13.1378 2.8861C12.4538 2.20211 11.3823 2.20438 10.7443 2.84245L7.6976 5.88911L7.69317 5.89349C7.05959 6.53211 7.05894 7.60014 7.74132 8.28252C7.97954 8.52074 7.97954 8.90697 7.74132 9.14519C7.5031 9.38341 7.11687 9.38341 6.87865 9.14519C5.74016 8.00671 5.69884 6.16251 6.83497 5.02633L6.84021 5.02116L9.8816 1.97978Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.61426 7.2364C4.85248 6.99818 5.23871 6.99818 5.47693 7.2364C5.71515 7.47462 5.71515 7.86085 5.47693 8.09907L2.83183 10.7442C2.19375 11.3823 2.1915 12.4537 2.87547 13.1377C3.55945 13.8217 4.6309 13.8194 5.26899 13.1813L8.31566 10.1347C8.32262 10.1277 8.32971 10.121 8.33691 10.1144C8.34408 10.1064 8.3515 10.0986 8.35916 10.091C8.99721 9.45291 8.99949 8.38145 8.3155 7.69746C8.07728 7.45924 8.07728 7.07301 8.3155 6.83479C8.55372 6.59657 8.93995 6.59657 9.17817 6.83479C10.3166 7.97327 10.358 9.81748 9.22183 10.9536C9.21487 10.9606 9.20779 10.9673 9.20058 10.9739C9.19341 10.9819 9.18599 10.9897 9.17833 10.9973L6.13166 14.044C4.99548 15.1802 3.15127 15.1389 2.01279 14.0004C0.874362 12.8619 0.83297 11.0177 1.96916 9.8815L4.61426 7.2364Z"}}]},We=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"link-single",ref:n,icon:an}))});We.displayName="LinkSingle";var cn={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"}}]},dt=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"unlink-single",ref:n,icon:cn}))});dt.displayName="UnlinkSingle";var ln={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"}}]},pt=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"write-single",ref:n,icon:ln}))});pt.displayName="WriteSingle";var un={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"#35BD4B",d:"M3.4535 1.12549C2.7002 1.12549 2.08954 1.73615 2.08954 2.48945V13.5104C2.08954 14.2637 2.7002 14.8744 3.4535 14.8744H12.5465C13.2998 14.8744 13.9105 14.2637 13.9105 13.5104V5.0992L10.0091 1.12549H3.4535Z"}},{tag:"path",attrs:{fill:"#32A846",d:"M10.0075 1.12549L13.9104 5.09842H10.6742C10.306 5.09842 10.0075 4.79994 10.0075 4.43175V1.12549Z"}},{tag:"path",attrs:{fill:"#fff",d:"M7.8088 10.2949L6.3764 12.403C6.26259 12.5705 6.03455 12.614 5.86705 12.5002C5.69955 12.3864 5.65603 12.1584 5.76984 11.9909L7.3655 9.64252L5.94042 7.54519C5.82661 7.37769 5.87013 7.14964 6.03763 7.03583C6.20512 6.92202 6.43317 6.96555 6.54698 7.13304L7.8088 8.9901L9.07062 7.13304C9.18443 6.96555 9.41248 6.92202 9.57997 7.03583C9.74747 7.14964 9.79099 7.37769 9.67718 7.54519L8.2521 9.64252L9.84776 11.9909C9.96157 12.1584 9.91805 12.3864 9.75055 12.5002C9.58305 12.614 9.35501 12.5705 9.2412 12.403L7.8088 10.2949Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ht=C.forwardRef(function(e,n){return C.createElement(re,Object.assign({},e,{id:"xlsx",ref:n,icon:un}))});ht.displayName="Xlsx";function vt(e){var n,t,i="";if(typeof e=="string"||typeof e=="number")i+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(t=vt(e[n]))&&(i&&(i+=" "),i+=t)}else for(t in e)e[t]&&(i&&(i+=" "),i+=t);return i}function gt(){for(var e,n,t=0,i="",r=arguments.length;t<r;t++)(e=arguments[t])&&(n=vt(e))&&(i&&(i+=" "),i+=n);return i}const Y={cellLink:"univer-cell-link",cellLinkType:"univer-cell-link-type",cellLinkContent:"univer-cell-link-content",cellLinkContentError:"univer-cell-link-content-error",cellLinkUrl:"univer-cell-link-url",cellLinkOperations:"univer-cell-link-operations",cellLinkOperation:"univer-cell-link-operation",cellLinkOperationError:"univer-cell-link-operation-error"},dn={[S.SheetHyperLinkType.URL]:m.jsx(We,{}),[S.SheetHyperLinkType.SHEET]:m.jsx(ht,{}),[S.SheetHyperLinkType.RANGE]:m.jsx(Te,{}),[S.SheetHyperLinkType.DEFINE_NAME]:m.jsx(Te,{}),[S.SheetHyperLinkType.INVALID]:m.jsx(Te,{})},St=e=>{var x,U;const n=o.useDependency(g.SheetsHyperLinkPopupService),t=o.useDependency(o.ICommandService),i=o.useDependency(b.IMessageService),r=o.useDependency(o.LocaleService),a=o.useDependency(g.SheetsHyperLinkResolverService),s=o.useDependency(y.IEditorBridgeService),l=o.useDependency(S.SheetsHyperLinkParserService),u=o.useDependency(b.IZenZoneService),{customRange:p,row:d,col:h,unitId:_,subUnitId:v,editPermission:E,copyPermission:L,type:O}=e;if(!((x=p==null?void 0:p.properties)!=null&&x.url))return null;const c=l.parseHyperLink((U=p.properties.url)!=null?U:""),D=c.type===S.SheetHyperLinkType.INVALID;return m.jsxs("div",{className:Y.cellLink,onClick:()=>n.hideCurrentPopup(),children:[m.jsxs("div",{className:gt(Y.cellLinkContent,{[Y.cellLinkContentError]:D}),onClick:()=>{u.visible||D||a.navigate(c)},children:[m.jsx("div",{className:Y.cellLinkType,children:dn[c.type]}),m.jsx(w.Tooltip,{showIfEllipsis:!0,title:c.name,asChild:!0,children:m.jsx("span",{className:Y.cellLinkUrl,children:c.name})})]}),m.jsxs("div",{className:Y.cellLinkOperations,children:[L&&m.jsx("div",{className:gt(Y.cellLinkOperation,{[Y.cellLinkOperationError]:D}),onClick:()=>{if(!D){if(c.type!==S.SheetHyperLinkType.URL){const N=new URL(window.location.href);N.hash=c.url.slice(1),navigator.clipboard.writeText(N.href)}else navigator.clipboard.writeText(c.url);i.show({content:r.t("hyperLink.message.coped"),type:w.MessageType.Info})}},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.copy"),children:m.jsx(ut,{})})}),E&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{t.executeCommand(De.id,{unitId:_,subUnitId:v,row:d,col:h,customRangeId:p.rangeId,type:O})},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.edit"),children:m.jsx(pt,{})})}),m.jsx("div",{className:Y.cellLinkOperation,onClick:()=>{const N=O===f.EDITING||O===f.ZEN_EDITOR?S.CancelRichHyperLinkCommand.id:S.CancelHyperLinkCommand.id;t.syncExecuteCommand(N,{unitId:_,subUnitId:v,id:p.rangeId,row:d,column:h,documentId:O===f.ZEN_EDITOR?o.DOCS_ZEN_EDITOR_UNIT_ID_KEY:s.getCurrentEditorId()})&&n.hideCurrentPopup(void 0,!0)},children:m.jsx(w.Tooltip,{placement:"bottom",title:r.t("hyperLink.popup.cancel"),children:m.jsx(dt,{})})})]})]})]})},Oe=()=>{var r,a;const e=o.useDependency(g.SheetsHyperLinkPopupService),[n,t]=C.useState(null),i=o.useDependency(o.IUniverInstanceService);if(C.useEffect(()=>{t(e.currentPopup);const s=e.currentPopup$.subscribe(l=>{t(l)});return()=>{s.unsubscribe()}},[e.currentPopup,e.currentPopup$]),!n)return null;if(n.showAll){const s=i.getUnit(n.unitId,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(n.subUnitId),u=l==null?void 0:l.getCell(n.row,n.col),p=(a=(r=u==null?void 0:u.p)==null?void 0:r.body)==null?void 0:a.customRanges;return p!=null&&p.length?m.jsx("div",{children:p.map(d=>m.jsx(St,{...n,customRange:d},d.rangeId))}):null}return m.jsx(St,{...n})};Oe.componentKey="univer.sheet.cell-link-popup";var pn=Object.defineProperty,hn=Object.getOwnPropertyDescriptor,vn=(e,n,t,i)=>{for(var r=i>1?void 0:i?hn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&pn(n,t,r),r},oe=(e,n)=>(t,i)=>n(t,i,e);const _t=(e,n)=>{var t,i;return e.unitId===n.unitId&&e.subUnitId===n.subUnitId&&e.row===n.row&&e.col===n.col&&((t=e.customRange)==null?void 0:t.rangeId)===((i=n.customRange)==null?void 0:i.rangeId)&&e.type===n.type};g.SheetsHyperLinkPopupService=class extends o.Disposable{constructor(t,i,r,a,s,l,u){super();K(this,"_currentPopup",null);K(this,"_currentPopup$",new P.Subject);K(this,"currentPopup$",this._currentPopup$.asObservable());K(this,"_currentEditingPopup",null);K(this,"_currentEditing$",new P.BehaviorSubject(null));K(this,"currentEditing$",this._currentEditing$.asObservable());K(this,"_isKeepVisible",!1);this._sheetCanvasPopManagerService=t,this._injector=i,this._univerInstanceService=r,this._editorBridgeService=a,this._textSelectionManagerService=s,this._docCanvasPopManagerService=l,this._zenZoneService=u,this.disposeWithMe(()=>{this.hideCurrentPopup(),this.endEditing(),this._currentEditing$.complete(),this._currentPopup$.complete()})}get currentPopup(){return this._currentPopup}get currentEditing(){return this._currentEditing$.getValue()}setIsKeepVisible(t){this._isKeepVisible=t}getIsKeepVisible(){return this._isKeepVisible}showPopup(t){if(this._currentPopup&&_t(t,this._currentPopup)||(this.hideCurrentPopup(void 0,!0),t.type!==f.ZEN_EDITOR&&this._zenZoneService.visible))return;const i=this._currentEditing$.getValue();if(i&&_t(t,i))return;const{unitId:r,subUnitId:a,row:s,col:l,customRangeRect:u,customRange:p}=t;let d;const h={componentKey:Oe.componentKey,direction:"bottom",onClickOutside:()=>{this.hideCurrentPopup()},onClick:()=>{this.hideCurrentPopup(t.type,!0)}};if(t.type===f.EDITING){if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(u,h)}else if(t.type===f.ZEN_EDITOR){if(!p)return;d=this._docCanvasPopManagerService.attachPopupToRange({startOffset:p.startIndex,endOffset:p.endIndex+1,collapsed:!1},h,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.showAll)d=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,h,r,a);else{if(!p)return;d=u&&this._sheetCanvasPopManagerService.attachPopupByPosition(u,h,t)}d&&(this._currentPopup={unitId:r,subUnitId:a,disposable:d,row:s,col:l,editPermission:!!t.editPermission,copyPermission:!!t.copyPermission,customRange:p,type:t.type,showAll:t.showAll},this._currentPopup$.next(this._currentPopup))}hideCurrentPopup(t,i){var r,a;this._currentPopup&&((!t||t===this._currentPopup.type)&&this._currentPopup.disposable.canDispose()||i)&&((a=(r=this._currentPopup)==null?void 0:r.disposable)==null||a.dispose(),this._currentPopup=null,this._currentPopup$.next(null))}_getEditingRange(){var r,a,s;const t=this._editorBridgeService.isVisible().visible,i=this._editorBridgeService.getEditCellState();if(t&&i){const l=this._textSelectionManagerService.getActiveTextRange(),u=(r=i.documentLayoutObject.documentModel)==null?void 0:r.getBody();if(!u)return null;if(!l||l.collapsed)return{startOffset:0,endOffset:u.dataStream.length-2,collapsed:u.dataStream.length-2===0,label:o.BuildTextUtils.transform.getPlainText(u.dataStream)};const p=o.BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(l,(s=(a=u.customRanges)==null?void 0:a.filter(_=>_.rangeType===o.CustomRangeType.HYPERLINK))!=null?s:[]);let d=l.startOffset,h=l.endOffset;return p.forEach(_=>{d=Math.min(d,_.startIndex),h=Math.max(h,_.endIndex+1)}),{startOffset:d,endOffset:h,collapsed:d===h,label:o.BuildTextUtils.transform.getPlainText(u.dataStream.slice(d,h))}}return null}get _editPopup(){return{componentKey:Le.componentKey,direction:"vertical",onClickOutside:()=>{this.getIsKeepVisible()||this.endEditing()},onContextMenu:()=>{this.getIsKeepVisible()||this.endEditing()},hiddenType:"hide"}}startAddEditing(t){var s,l,u,p,d;const{unitId:i,subUnitId:r,type:a}=t;if(a===f.ZEN_EDITOR){const h=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(!h)return;const _=this._textSelectionManagerService.getActiveTextRange();if(!_)return;this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange(_,this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY);const v=(s=h.getBody())==null?void 0:s.dataStream.slice(_.startOffset,_.endOffset);this._currentEditing$.next({...t,label:v})}else if(a===f.EDITING){const h=this._getEditingRange();if(!h)return;this._textSelectionManagerService.replaceDocRanges([{...h}],{unitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY,subUnitId:o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY});const _=this._injector.get(pe.IRenderManagerService).getRenderById(o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY);if(!_)return;const v=ee.calcDocRangePositions(h,_);if(!(v!=null&&v.length))return;this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.pop(),this._editPopup,i,r),this._currentEditing$.next({...t,label:(l=h==null?void 0:h.label)!=null?l:""})}else{this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r);const h=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),_=h==null?void 0:h.getSheetBySheetId(r),v=_==null?void 0:_.getCellRaw(t.row,t.col);this._currentEditing$.next({...t,label:v!=null&&v.p?o.BuildTextUtils.transform.getPlainText((p=(u=v.p.body)==null?void 0:u.dataStream)!=null?p:""):((d=v==null?void 0:v.v)!=null?d:"").toString()})}}startEditing(t){var l,u,p,d,h,_;(l=this._currentEditingPopup)==null||l.dispose(),this.hideCurrentPopup(void 0,!0);const{unitId:i,subUnitId:r}=t;let a,s;if(t.type===f.ZEN_EDITOR){const v=this._univerInstanceService.getUnit(o.DOCS_ZEN_EDITOR_UNIT_ID_KEY,o.UniverInstanceType.UNIVER_DOC);if(a=(p=(u=v==null?void 0:v.getBody())==null?void 0:u.customRanges)==null?void 0:p.find(E=>E.rangeId===t.customRangeId),s=a?(d=v==null?void 0:v.getBody())==null?void 0:d.dataStream.slice(a.startIndex,a.endIndex+1):"",!a||!s)return;this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._docCanvasPopManagerService.attachPopupToRange({startOffset:a.startIndex,endOffset:a.endIndex,collapsed:!1},this._editPopup,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)}else if(t.type===f.EDITING){const v=y.getEditingCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!v||!((h=v.rects)!=null&&h.length))return;a=v.customRange,s=v.label,this._textSelectionManagerService.replaceTextRanges([{startOffset:a.startIndex,endOffset:a.endIndex+1}]),this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToAbsolutePosition(v.rects.pop(),this._editPopup,i,r)}else{const v=this._univerInstanceService.getUnit(i,o.UniverInstanceType.UNIVER_SHEET),E=v==null?void 0:v.getSheetBySheetId(r),L=E==null?void 0:E.getCellRaw(t.row,t.col),O=v==null?void 0:v.getStyles().getStyleByCell(L),c=O==null?void 0:O.tr,D=y.getCustomRangePosition(this._injector,t.unitId,t.subUnitId,t.row,t.col,t.customRangeId);if(!D||!((_=D.rects)!=null&&_.length))return;a=D.customRange,s=D.label,c?this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupToCell(t.row,t.col,this._editPopup,i,r):this._currentEditingPopup=this._sheetCanvasPopManagerService.attachPopupByPosition(D.rects.pop(),this._editPopup,{unitId:i,subUnitId:r,row:t.row,col:t.col})}this._currentEditing$.next({...t,customRange:a,label:s})}endEditing(t){var r;const i=this._currentEditing$.getValue();i&&(!t||t===i.type)&&((r=this._currentEditingPopup)==null||r.dispose(),this._currentEditing$.next(null))}},g.SheetsHyperLinkPopupService=vn([oe(0,o.Inject(y.SheetCanvasPopManagerService)),oe(1,o.Inject(o.Injector)),oe(2,o.IUniverInstanceService),oe(3,y.IEditorBridgeService),oe(4,o.Inject(he.DocSelectionManagerService)),oe(5,o.Inject(ee.DocCanvasPopManagerService)),oe(6,b.IZenZoneService)],g.SheetsHyperLinkPopupService);var ge=(e=>(e[e.ALLOWED=0]="ALLOWED",e[e.DISABLED_BY_CELL=1]="DISABLED_BY_CELL",e[e.ALLOW_ON_EDITING=2]="ALLOW_ON_EDITING",e))(ge||{});const gn=new Set([o.DataValidationType.CHECKBOX,o.DataValidationType.LIST,o.DataValidationType.LIST_MULTIPLE]),Ke=(e,n,t,i)=>{var l,u;const r=n.getCell(t,i);if(r!=null&&r.f||r!=null&&r.si)return 1;const a=e.has(it.SheetDataValidationModel)?e.get(it.SheetDataValidationModel):null,s=a==null?void 0:a.getRuleByLocation(n.getUnitId(),n.getSheetId(),t,i);return s&&gn.has(s.type)?!0:(u=(l=r==null?void 0:r.p)==null?void 0:l.drawingsOrder)!=null&&u.length?2:0},Sn=e=>{const n=e.get(o.IUniverInstanceService).getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!n)return!0;const t=n.getActiveSheet(),i=e.get(R.SheetsSelectionsService).getCurrentSelections();if(!i.length)return!0;const r=i[0].range.startRow,a=i[0].range.startColumn;return Ke(e,t,r,a)===1},_n=e=>{const n=e.get(he.DocSelectionManagerService),t=e.get(o.IUniverInstanceService),i=n.getTextRanges();if(!(i!=null&&i.length))return!0;const r=t.getCurrentUnitForType(o.UniverInstanceType.UNIVER_DOC);return!!(!r||i.every(s=>s.collapsed)||!r.getSelfOrHeaderFooterModel(i[0].segmentId).getBody())},De={type:o.CommandType.OPERATION,id:"sheet.operation.open-hyper-link-edit-panel",handler(e,n){if(!n)return!1;const t=e.get(g.SheetsHyperLinkPopupService);return n.customRangeId?t.startEditing(n):t.startAddEditing(n),!0}},Se={type:o.CommandType.OPERATION,id:"sheet.operation.close-hyper-link-popup",handler(e){return e.get(g.SheetsHyperLinkPopupService).endEditing(),!0}},ke={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link",handler(e){var h;const n=e.get(o.IUniverInstanceService),t=R.getSheetCommandTarget(n),i=e.get(y.IEditorBridgeService);if(!t)return!1;const r=e.get(o.ICommandService),s=e.get(R.SheetsSelectionsService).getCurrentLastSelection();if(!s)return!1;const l=s.range.startRow,u=s.range.startColumn,p=i.isVisible(),d=((h=n.getFocusedUnit())==null?void 0:h.getUnitId())===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY;return r.executeCommand(De.id,{unitId:t.unitId,subUnitId:t.subUnitId,row:l,col:u,type:d?f.ZEN_EDITOR:p.visible?f.EDITING:f.VIEWING})}},se={type:o.CommandType.OPERATION,id:"sheet.operation.insert-hyper-link-toolbar",handler(e){if(Sn(e))return!1;const n=e.get(o.ICommandService);return e.get(g.SheetsHyperLinkPopupService).currentEditing?n.executeCommand(Se.id):n.executeCommand(ke.id)}},Ye=(e,n=o.DOCS_ZEN_EDITOR_UNIT_ID_KEY)=>{var r;const t=e.get(o.IUniverInstanceService),i=(r=e.get(pe.IRenderManagerService).getRenderById(n))==null?void 0:r.with(ee.DocSelectionRenderService);return i?i.textSelectionInner$.pipe(P.map(()=>{const s=e.get(y.IEditorBridgeService).getEditCellState();if(!s)return!0;const l=R.getSheetCommandTarget(t,{unitId:s.unitId,subUnitId:s.sheetId});return!(l!=null&&l.worksheet)||Ke(e,l.worksheet,s.row,s.column)===1?!0:_n(e)})):P.of(!0)},It=e=>{const n=y.getCurrentRangeDisable$(e,{workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},!0),t=e.get(o.IUniverInstanceService),i=e.get(R.SheetsSelectionsService),r=e.has(y.IEditorBridgeService)?e.get(y.IEditorBridgeService):null,a=t.focused$.pipe(P.filter(s=>!!s),P.map(s=>t.getUnit(s,o.UniverInstanceType.UNIVER_SHEET)),P.filter(s=>!!s),P.switchMap(s=>s.activeSheet$),P.switchMap(s=>i.selectionMoveEnd$.pipe(P.map(l=>s&&{selections:l,sheet:s}))),P.map(s=>{if(!s)return ge.DISABLED_BY_CELL;const{selections:l,sheet:u}=s;if(!l.length)return ge.DISABLED_BY_CELL;const p=l[0].range.startRow,d=l[0].range.startColumn;return Ke(e,u,p,d)}),P.switchMap(s=>{if(s===ge.DISABLED_BY_CELL)return P.of(!0);const l=(r?r.visible$:P.of(null)).pipe(P.map(p=>p!=null&&p.visible?o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY:void 0)),u=e.get(o.IContextService).subscribeContextValue$(o.FOCUSING_FX_BAR_EDITOR);return P.combineLatest([l,u]).pipe(P.switchMap(([p,d])=>p?d?P.of(!0):Ye(e,p):P.of(s===ge.ALLOW_ON_EDITING)))}));return n.pipe(P.distinctUntilChanged(),P.switchMap(s=>a.pipe(P.map(l=>s||l))))},be={commandId:ke.id,type:b.MenuItemType.BUTTON,title:"hyperLink.menu.add",icon:"LinkSingle"},we=e=>`${e}-zen-editor`,In=e=>({...be,id:be.commandId,hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:It(e)}),mn=e=>({...be,id:we(be.commandId),hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ye(e)}),Ne={tooltip:"hyperLink.form.addTitle",commandId:se.id,type:b.MenuItemType.BUTTON,icon:"LinkSingle"},fn=e=>({...Ne,id:Ne.commandId,hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:It(e)}),yn=e=>({...Ne,id:we(Ne.commandId),hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_DOC,o.DOCS_ZEN_EDITOR_UNIT_ID_KEY),disabled$:Ye(e)}),Ge={id:se.id,binding:b.KeyCode.K|b.MetaKeys.CTRL_COMMAND,preconditions:y.whenSheetEditorFocused};var Cn=Object.defineProperty,En=Object.getOwnPropertyDescriptor,Rn=(e,n,t,i)=>{for(var r=i>1?void 0:i?En(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Cn(n,t,r),r},mt=(e,n)=>(t,i)=>n(t,i,e);let Me=class extends o.Disposable{constructor(e,n){super(),this._autoFillService=e,this._hyperLinkModel=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),n=(i,r)=>{const{source:a,target:s,unitId:l,subUnitId:u}=i,p=y.virtualizeDiscreteRanges([a,s]),[d,h]=p.ranges,{mapFunc:_}=p,v={row:d.startRow,col:d.startColumn},E=y.getAutoFillRepeatRange(d,h),L=[],O=[];return E.forEach(c=>{const D=c.repeatStartCell,x=c.relativeRange,U={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},N={startRow:D.row,startColumn:D.col,endColumn:D.col,endRow:D.row};o.Range.foreach(x,(Z,F)=>{const Q=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},U),{row:Ie,col:Ae}=_(Q.startRow,Q.startColumn),ae=this._hyperLinkModel.getHyperLinkByLocation(l,u,Ie,Ae),me=o.Rectangle.getPositionRange({startRow:Z,startColumn:F,endColumn:F,endRow:Z},N),{row:fe,col:ye}=_(me.startRow,me.startColumn),ce=o.Tools.generateRandomId(),W=this._hyperLinkModel.getHyperLinkByLocation(l,u,fe,ye);W&&L.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:W.id}}),(y.APPLY_TYPE.COPY===r||y.APPLY_TYPE.SERIES===r)&&ae&&(L.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:{...ae,id:ce,row:fe,column:ye}}}),O.push({id:S.RemoveHyperLinkMutation.id,params:{unitId:l,subUnitId:u,id:ce}})),W&&O.push({id:S.AddHyperLinkMutation.id,params:{unitId:l,subUnitId:u,link:W}})})}),{undos:O,redos:L}},t={id:Ve,onFillData:(i,r,a)=>a===y.APPLY_TYPE.COPY||a===y.APPLY_TYPE.ONLY_FORMAT||a===y.APPLY_TYPE.SERIES?n(i,a):e()};this.disposeWithMe(this._autoFillService.addHook(t))}};Me=Rn([mt(0,y.IAutoFillService),mt(1,o.Inject(S.HyperLinkModel))],Me);var Pn=Object.defineProperty,Ln=Object.getOwnPropertyDescriptor,Tn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Ln(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Pn(n,t,r),r},$e=(e,n)=>(t,i)=>n(t,i,e);let Ue=class extends o.Disposable{constructor(e,n,t){super(),this._localeService=e,this._commandService=n,this._sheetPermissionInterceptorBaseController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{e.id===Ge.id&&(this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],rangeTypes:[R.RangeProtectionPermissionEditPoint],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetSetCellValuePermission,R.WorksheetInsertHyperlinkPermission]})||this._sheetPermissionInterceptorBaseController.haveNotPermissionHandle(this._localeService.t("permission.dialog.hyperLinkErr")))}))}};Ue=Tn([$e(0,o.Inject(o.LocaleService)),$e(1,o.ICommandService),$e(2,o.Inject(y.SheetPermissionInterceptorBaseController))],Ue);var On=Object.defineProperty,Dn=Object.getOwnPropertyDescriptor,kn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Dn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&On(n,t,r),r},G=(e,n)=>(t,i)=>n(t,i,e);let He=class extends o.Disposable{constructor(e,n,t,i,r,a,s,l,u,p){super(),this._hoverManagerService=e,this._sheetsHyperLinkPopupService=n,this._renderManagerService=t,this._permissionService=i,this._sheetPermissionInterceptorBaseController=r,this._commandService=a,this._editorBridgeService=s,this._textSelectionManagerService=l,this._univerInstanceService=u,this._zenZoneService=p,this._initHoverListener(),this._initCommandListener(),this._initHoverEditingListener(),this._initTextSelectionListener(),this._initZenEditor()}_getLinkPermission(e){const{unitId:n,subUnitId:t,row:i,col:r}=e,a=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET);if(!(a==null?void 0:a.getSheetBySheetId(t)))return{viewPermission:!1,editPermission:!1,copyPermission:!1};const l=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookViewPermission],worksheetTypes:[R.WorksheetViewPermission],rangeTypes:[R.RangeProtectionPermissionViewPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),u=this._sheetPermissionInterceptorBaseController.permissionCheckWithRanges({workbookTypes:[R.WorkbookEditablePermission],worksheetTypes:[R.WorksheetEditPermission,R.WorksheetInsertHyperlinkPermission],rangeTypes:[R.RangeProtectionPermissionEditPoint]},[{startRow:i,startColumn:r,endRow:i,endColumn:r}]),p=this._permissionService.composePermission([new R.WorkbookCopyPermission(n).id,new R.WorksheetCopyPermission(n,t).id]).every(d=>d.value);return{viewPermission:l,editPermission:u,copyPermission:p}}_initHoverListener(){this.disposeWithMe(this._hoverManagerService.currentRichText$.pipe(P.debounceTime(200)).subscribe(e=>{var U,N;if(!e){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const{unitId:n,subUnitId:t,row:i,col:r}=e,a=this._renderManagerService.getRenderById(n);if(!a)return;const s=this._univerInstanceService.getUnit(n,o.UniverInstanceType.UNIVER_SHEET),l=s==null?void 0:s.getSheetBySheetId(t);if(!l)return;if(!a.with(y.HoverRenderController).active){this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING);return}const p=(U=a==null?void 0:a.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(t))==null?void 0:U.skeleton,d=r,h=i;let _=h,v=d;p&&p.overflowCache.forValue((Z,F,Q)=>{o.Rectangle.contains(Q,{startColumn:d,endColumn:d,startRow:h,endRow:h})&&(_=Z,v=F)});const{viewPermission:E,editPermission:L,copyPermission:O}=this._getLinkPermission(e);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const c=l.getCellStyleOnly(_,v),D=s.getStyles().getStyleByCell(c),x=(N=D==null?void 0:D.tr)==null?void 0:N.a;if(!x&&!e.customRange){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}this._sheetsHyperLinkPopupService.showPopup({row:_,col:v,editPermission:L,copyPermission:O,customRange:e.customRange,customRangeRect:e.rect,type:f.VIEWING,unitId:n,subUnitId:t,showAll:!!x})}))}_initHoverEditingListener(){let e=null;this.disposeWithMe(this._editorBridgeService.currentEditCellState$.pipe(P.switchMap(n=>this._editorBridgeService.visible$.pipe(P.map(t=>({visible:t,state:n}))))).subscribe(({visible:n,state:t})=>{if(!t||t.editorUnitId!==o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY)return;if(!n.visible){e==null||e.unsubscribe(),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING);return}const{editorUnitId:i,unitId:r,sheetId:a,row:s,column:l}=t,u=this._renderManagerService.getRenderById(i);if(!u)return;const{editPermission:p,viewPermission:d,copyPermission:h}=this._getLinkPermission({unitId:r,subUnitId:a,row:s,col:l}),_=u.with(ee.DocEventManagerService);d&&(e==null||e.unsubscribe(),e=_.hoverCustomRanges$.pipe(P.debounceTime(200)).subscribe(v=>{var D,x;const E=v.find(U=>U.range.rangeType===o.CustomRangeType.HYPERLINK);if(!E){this._sheetsHyperLinkPopupService.hideCurrentPopup();return}const L=E.rects[E.rects.length-1];if(!((x=(D=this._renderManagerService.getRenderById(r))==null?void 0:D.with(y.SheetSkeletonManagerService).getWorksheetSkeleton(a))==null?void 0:x.skeleton)||!L)return;const c=u.engine.getCanvasElement().getBoundingClientRect();this._sheetsHyperLinkPopupService.showPopup({unitId:r,subUnitId:a,row:s,col:l,customRange:E.range,customRangeRect:{left:L.left+c.left,top:L.top+c.top,bottom:L.bottom+c.top,right:L.right+c.left},editPermission:p,copyPermission:h,type:f.EDITING})}))})),this.disposeWithMe(()=>{e==null||e.unsubscribe()})}_initZenEditor(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e?(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.EDITING),this._sheetsHyperLinkPopupService.endEditing(f.EDITING),this._sheetsHyperLinkPopupService.hideCurrentPopup(f.VIEWING)):(this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR),this._sheetsHyperLinkPopupService.endEditing(f.ZEN_EDITOR))})),this.disposeWithMe(this._univerInstanceService.focused$.pipe(P.switchMap(e=>{const n=e===o.DOCS_ZEN_EDITOR_UNIT_ID_KEY?this._renderManagerService.getRenderById(e):null;return n?n.with(ee.DocEventManagerService).hoverCustomRanges$.pipe(P.debounceTime(200)):new P.Observable(t=>{t.next(null)})})).subscribe(e=>{const n=e==null?void 0:e.find(i=>i.range.rangeType===o.CustomRangeType.HYPERLINK),t=this._editorBridgeService.getEditCellState();if(n&&t){const{unitId:i,sheetId:r,row:a,column:s}=t,{editPermission:l,viewPermission:u,copyPermission:p}=this._getLinkPermission({unitId:i,subUnitId:r,row:a,col:s});u&&this._sheetsHyperLinkPopupService.showPopup({type:f.ZEN_EDITOR,unitId:i,subUnitId:r,row:a,col:s,customRange:n.range,editPermission:l,copyPermission:p})}else this._sheetsHyperLinkPopupService.hideCurrentPopup(f.ZEN_EDITOR)}))}_initTextSelectionListener(){this.disposeWithMe(this._textSelectionManagerService.textSelection$.subscribe(e=>{e&&e.unitId===o.DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&this._sheetsHyperLinkPopupService.endEditing(f.EDITING)}))}_initCommandListener(){const e=[R.ClearSelectionContentCommand.id,R.ClearSelectionAllCommand.id,R.ClearSelectionFormatCommand.id];this.disposeWithMe(this._commandService.onCommandExecuted(n=>{e.includes(n.id)&&this._sheetsHyperLinkPopupService.hideCurrentPopup()}))}};He=kn([G(0,o.Inject(y.HoverManagerService)),G(1,o.Inject(g.SheetsHyperLinkPopupService)),G(2,o.Inject(pe.IRenderManagerService)),G(3,o.Inject(o.IPermissionService)),G(4,o.Inject(y.SheetPermissionInterceptorBaseController)),G(5,o.ICommandService),G(6,y.IEditorBridgeService),G(7,o.Inject(he.DocSelectionManagerService)),G(8,o.IUniverInstanceService),G(9,b.IZenZoneService)],He);var bn=Object.defineProperty,wn=Object.getOwnPropertyDescriptor,ft=(e,n,t,i)=>{for(var r=i>1?void 0:i?wn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&bn(n,t,r),r},ze=(e,n)=>(t,i)=>n(t,i,e);let Je=class extends o.Disposable{constructor(e,n){super(),this._context=e,this._hyperLinkModel=n,this._initSkeletonChange()}_initSkeletonChange(){const e=()=>{var n;(n=this._context.mainComponent)==null||n.makeForceDirty()};this.disposeWithMe(this._hyperLinkModel.linkUpdate$.pipe(P.debounceTime(16)).subscribe(()=>{e()}))}};Je=ft([ze(1,o.Inject(S.HyperLinkModel))],Je);let je=class extends o.Disposable{constructor(e,n){super(),this._sheetInterceptorService=e,this._hyperLinkModel=n,this._initViewModelIntercept()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(R.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Value,priority:100,handler:(e,n,t)=>{const{row:i,col:r,unitId:a,subUnitId:s}=n,l=this._hyperLinkModel.getHyperLinkByLocation(a,s,i,r);return t(l?{...e,linkUrl:l.payload,linkId:l.id}:e)}}))}};je=ft([ze(0,o.Inject(R.SheetInterceptorService)),ze(1,o.Inject(S.HyperLinkModel))],je);const Nn={[b.RibbonStartGroup.OTHERS]:{[se.id]:{order:2,menuItemFactory:fn},[we(se.id)]:{order:2,menuItemFactory:yn}},[b.ContextMenuPosition.MAIN_AREA]:{[b.ContextMenuGroup.OTHERS]:{order:1,[se.id]:{order:0,menuItemFactory:In},[we(se.id)]:{order:0,menuItemFactory:mn}}}};var Mn=Object.defineProperty,Un=Object.getOwnPropertyDescriptor,Hn=(e,n,t,i)=>{for(var r=i>1?void 0:i?Un(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Mn(n,t,r),r},_e=(e,n)=>(t,i)=>n(t,i,e);let xe=class extends o.Disposable{constructor(e,n,t,i,r){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=t,this._injector=i,this._shortcutService=r,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortCut()}_initComponents(){[[Oe,Oe.componentKey],[Le,Le.componentKey],[We,"LinkSingle"]].forEach(([e,n])=>{this._componentManager.register(n,e)})}_initCommands(){[De,Se,ke,se].forEach(e=>{this._commandService.registerCommand(e)})}_initMenus(){this._menuManagerService.mergeMenu(Nn)}_initShortCut(){this._shortcutService.registerShortcut(Ge)}};xe=Hn([_e(0,o.Inject(b.ComponentManager)),_e(1,o.ICommandService),_e(2,b.IMenuManagerService),_e(3,o.Inject(o.Injector)),_e(4,o.Inject(b.IShortcutService))],xe);var jn=Object.defineProperty,xn=Object.getOwnPropertyDescriptor,Bn=(e,n,t,i)=>{for(var r=i>1?void 0:i?xn(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&jn(n,t,r),r},yt=(e,n)=>(t,i)=>n(t,i,e);let Be=class extends o.Disposable{constructor(e,n){super(),this._parserService=e,this._resolverService=n,this._handleInitUrl()}_handleInitUrl(){const e=location.hash;if(e){const n=this._parserService.parseHyperLink(e);this._resolverService.navigate(n)}}};Be=Bn([yt(0,o.Inject(S.SheetsHyperLinkParserService)),yt(1,o.Inject(g.SheetsHyperLinkResolverService))],Be);var Ct=Object.defineProperty,An=Object.getOwnPropertyDescriptor,Vn=(e,n,t)=>n in e?Ct(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Fn=(e,n,t,i)=>{for(var r=i>1?void 0:i?An(n,t):n,a=e.length-1,s;a>=0;a--)(s=e[a])&&(r=(i?s(n,t,r):s(r))||r);return i&&r&&Ct(n,t,r),r},Et=(e,n)=>(t,i)=>n(t,i,e),Rt=(e,n,t)=>Vn(e,typeof n!="symbol"?n+"":n,t);g.UniverSheetsHyperLinkUIPlugin=class extends o.Plugin{constructor(n=ot,t,i){super(),this._config=n,this._injector=t,this._configService=i;const{menu:r,...a}=o.merge({},ot,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig(rt,a)}onStarting(){[[g.SheetsHyperLinkResolverService],[g.SheetsHyperLinkPopupService],[Ze],[je],[He],[xe],[Me],[g.SheetsHyperLinkCopyPasteController],[Ue],[Be]].forEach(t=>this._injector.add(t)),this._injector.get(je)}onReady(){this._injector.get(pe.IRenderManagerService).registerRenderModule(o.UniverInstanceType.UNIVER_SHEET,[Je]),this._injector.get(Me),this._injector.get(g.SheetsHyperLinkCopyPasteController),this._injector.get(xe)}onRendered(){this._injector.get(Ue),this._injector.get(Be),this._injector.get(He)}},Rt(g.UniverSheetsHyperLinkUIPlugin,"pluginName",Ve),Rt(g.UniverSheetsHyperLinkUIPlugin,"type",o.UniverInstanceType.UNIVER_SHEET),g.UniverSheetsHyperLinkUIPlugin=Fn([o.DependentOn(S.UniverSheetsHyperLinkPlugin,ee.UniverDocsUIPlugin),Et(1,o.Inject(o.Injector)),Et(2,o.IConfigService)],g.UniverSheetsHyperLinkUIPlugin),g.CloseHyperLinkPopupOperation=Se,g.InsertHyperLinkOperation=ke,g.InsertLinkShortcut=Ge,g.OpenHyperLinkEditPanelOperation=De,g.SheetsHyperLinkSidePanelService=Ze,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-hyper-link-ui",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -59,53 +59,29 @@
59
59
  "rxjs": ">=7.0.0"
60
60
  },
61
61
  "dependencies": {
62
- "@univerjs/icons": "^0.2.8",
62
+ "@univerjs/icons": "^0.2.10",
63
63
  "clsx": "^2.1.1",
64
- "@univerjs/design": "0.5.2",
65
- "@univerjs/docs": "0.5.2",
66
- "@univerjs/core": "0.5.2",
67
- "@univerjs/docs-ui": "0.5.2",
68
- "@univerjs/engine-formula": "0.5.2",
69
- "@univerjs/engine-render": "0.5.2",
70
- "@univerjs/sheets": "0.5.2",
71
- "@univerjs/sheets-data-validation": "0.5.2",
72
- "@univerjs/sheets-formula-ui": "0.5.2",
73
- "@univerjs/ui": "0.5.2",
74
- "@univerjs/sheets-ui": "0.5.2",
75
- "@univerjs/sheets-hyper-link": "0.5.2"
64
+ "@univerjs/design": "0.5.3",
65
+ "@univerjs/core": "0.5.3",
66
+ "@univerjs/docs": "0.5.3",
67
+ "@univerjs/docs-ui": "0.5.3",
68
+ "@univerjs/engine-formula": "0.5.3",
69
+ "@univerjs/engine-render": "0.5.3",
70
+ "@univerjs/sheets": "0.5.3",
71
+ "@univerjs/sheets-formula-ui": "0.5.3",
72
+ "@univerjs/sheets-data-validation": "0.5.3",
73
+ "@univerjs/sheets-hyper-link": "0.5.3",
74
+ "@univerjs/sheets-ui": "0.5.3",
75
+ "@univerjs/ui": "0.5.3"
76
76
  },
77
77
  "devDependencies": {
78
78
  "postcss": "^8.4.49",
79
79
  "react": "18.3.1",
80
80
  "rxjs": "^7.8.1",
81
- "tailwindcss": "^3.4.16",
82
81
  "typescript": "^5.7.2",
83
- "vite": "^6.0.3",
82
+ "vite": "^6.0.6",
84
83
  "vitest": "^2.1.8",
85
- "@univerjs-infra/shared": "0.5.2"
86
- },
87
- "space": {
88
- ".": {
89
- "import": "./lib/es/index.js",
90
- "require": "./lib/cjs/index.js",
91
- "types": "./lib/types/index.d.ts"
92
- },
93
- "./*": {
94
- "import": "./lib/es/*",
95
- "require": "./lib/cjs/*",
96
- "types": "./lib/types/index.d.ts"
97
- },
98
- "./locale/*": {
99
- "import": "./lib/es/locale/*.js",
100
- "require": "./lib/cjs/locale/*.js",
101
- "types": "./lib/types/locale/*.d.ts"
102
- },
103
- "./facade": {
104
- "import": "./lib/es/facade.js",
105
- "require": "./lib/cjs/facade.js",
106
- "types": "./lib/types/facade/index.d.ts"
107
- },
108
- "./lib/*": "./lib/*"
84
+ "@univerjs-infra/shared": "0.5.3"
109
85
  },
110
86
  "scripts": {
111
87
  "test": "vitest run",