/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@univerjs/docs-hyper-link-ui@0.21.0/lib/es/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{BuildTextUtils,CommandType,CustomRangeType,DOCS_NORMAL_EDITOR_UNIT_ID_KEY,DOCS_ZEN_EDITOR_UNIT_ID_KEY,DependentOn,Disposable,ICommandService,IConfigService,IUniverInstanceService,Inject,Injector,LocaleService,Plugin,Tools,UniverInstanceType,generateRandomId,getBodySlice,merge}from"@univerjs/core";import{UniverDocsHyperLinkPlugin}from"@univerjs/docs-hyper-link";import{IRenderManagerService}from"@univerjs/engine-render";import{DOC_INTERCEPTOR_POINT,DocInterceptorService,DocSelectionManagerService,DocSkeletonManagerService,SetTextSelectionsOperation,addCustomRangeBySelectionFactory,deleteCustomRangeFactory,replaceSelectionFactory}from"@univerjs/docs";import{DocCanvasPopManagerService,DocEventManagerService,DocRenderController,whenDocAndEditorFocused}from"@univerjs/docs-ui";import{BehaviorSubject,Observable,debounceTime,distinctUntilChanged,pairwise}from"rxjs";import{Button,FormLayout,Input,MessageType,Tooltip,borderClassName,clsx}from"@univerjs/design";import{ComponentManager,ContextMenuGroup,ContextMenuPosition,IMenuManagerService,IMessageService,IShortcutService,KeyCode,MenuItemType,MetaKeys,RibbonInsertGroup,getMenuHiddenObservable,useDependency,useObservable}from"@univerjs/ui";import{useEffect,useState}from"react";import{jsx,jsxs}from"react/jsx-runtime";import{CopyIcon,LinkIcon,UnlinkIcon,WriteIcon}from"@univerjs/icons";var name="@univerjs/docs-hyper-link-ui",version="0.21.0";const DOCS_HYPER_LINK_UI_PLUGIN_CONFIG_KEY="docs-hyper-link-ui.config",configSymbol=Symbol("docs-hyper-link-ui.config"),defaultPluginConfig={},AddDocHyperLinkCommand={type:CommandType.COMMAND,id:"docs.command.add-hyper-link",async handler(e,n){if(!n)return!1;const{payload:i,unitId:t,selections:r}=n,o=e.get(ICommandService),d=addCustomRangeBySelectionFactory(e,{rangeId:generateRandomId(),rangeType:CustomRangeType.HYPERLINK,properties:{url:i},unitId:t,selections:r});return!!d&&o.syncExecuteCommand(d.id,d.params)}},UpdateDocHyperLinkCommand={id:"docs.command.update-hyper-link",type:CommandType.COMMAND,handler(e,n){var i;if(!n)return!1;const{unitId:t,payload:r,segmentId:o,linkId:d}=n,c=e.get(ICommandService),s=e.get(IUniverInstanceService),a=e.get(DocSelectionManagerService).getActiveTextRange(),l=s.getUnit(t,UniverInstanceType.UNIVER_DOC);if(!a||!l)return!1;const u=null===(i=getBodySlice(l.getSelfOrHeaderFooterModel(o).getBody(),a.startOffset,a.endOffset).textRuns)||void 0===i?void 0:i[0];u&&(u.ed=n.label.length+1);const p=replaceSelectionFactory(e,{unitId:t,body:{dataStream:`${n.label}`,customRanges:[{rangeId:d,rangeType:CustomRangeType.HYPERLINK,startIndex:0,endIndex:n.label.length+1,properties:{url:r}}],textRuns:u?[u]:void 0},selection:{startOffset:a.startOffset,endOffset:a.endOffset,collapsed:!1,segmentId:o}});return!!p&&c.syncExecuteCommand(p.id,p.params)}};function isBlankInput(e){return 0===e.trim().length}function hasProtocol(e){return/^[a-zA-Z]+:\/\//.test(e)}function isEmail(e){return/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/.test(e)}function transformUrl(e){return hasProtocol(e)?e:isEmail(e)?`mailto://${e}`:`https://${e}`}const DocHyperLinkEdit=()=>{const e=useDependency(DocHyperLinkPopupService),n=useDependency(LocaleService),i=useObservable(e.editingLink$),t=useDependency(ICommandService),r=useDependency(IUniverInstanceService),o=useDependency(DocSelectionManagerService),[d,c]=useState(""),[s,a]=useState(""),[l,u]=useState(!1),p=Tools.isLegalUrl(d),v=i?r.getUnit(i.unitId,UniverInstanceType.UNIVER_DOC):r.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC);useEffect((()=>{var e,n,t;const r=o.getActiveTextRange();if(!r)return;if(i){var d,s;const e=null==v||null===(d=v.getSelfOrHeaderFooterModel(i.segmentId))||void 0===d?void 0:d.getBody(),n=null==e||null===(s=e.customRanges)||void 0===s?void 0:s.find((e=>(null==i?void 0:i.linkId)===e.rangeId&&e.startIndex===i.startIndex&&e.endIndex===i.endIndex));var l,u;if(v&&n)c(null!==(l=null===(u=n.properties)||void 0===u?void 0:u.url)&&void 0!==l?l:""),a(BuildTextUtils.transform.getPlainText(getBodySlice(e,n.startIndex,n.endIndex+1).dataStream));return}const p=null==v||null===(e=v.getSelfOrHeaderFooterModel(r.segmentId))||void 0===e?void 0:e.getBody(),m=p?r:null,I=m&&(null===(n=BuildTextUtils.customRange.getCustomRangesInterestsWithSelection(m,null!==(t=null==p?void 0:p.customRanges)&&void 0!==t?t:[]))||void 0===n?void 0:n[0]);var g,y;v&&I&&c(null!==(g=null==I||null===(y=I.properties)||void 0===y?void 0:y.url)&&void 0!==g?g:"")}),[v,i,o,r]);const m=()=>{if(u(!0),!p||!v)return;const n=transformUrl(d);if(i){if(isBlankInput(s))return;t.executeCommand(UpdateDocHyperLinkCommand.id,{unitId:v.getUnitId(),payload:n,linkId:i.linkId,label:s,segmentId:i.segmentId})}else t.executeCommand(AddDocHyperLinkCommand.id,{unitId:v.getUnitId(),payload:n});e.hideEditPopup()};if(v)return jsxs("div",{className:clsx("univer-box-border univer-w-[328px] univer-rounded-xl univer-bg-white univer-px-6 univer-py-5 univer-shadow dark:!univer-bg-gray-900",borderClassName),children:[jsxs("div",{children:[i?jsx(FormLayout,{label:n.t("docLink.edit.label"),error:l&&isBlankInput(s)?n.t("docLink.edit.labelError"):"",children:jsx(Input,{value:s,onChange:a,autoFocus:!0,onKeyDown:e=>{e.keyCode===KeyCode.ENTER&&m()}})}):null,jsx(FormLayout,{label:n.t("docLink.edit.address"),error:l&&!p?n.t("docLink.edit.addressError"):"",children:jsx(Input,{value:d,onChange:c,autoFocus:!0,onKeyDown:e=>{e.keyCode===KeyCode.ENTER&&m()}})})]}),jsxs("div",{className:"univer-flex univer-justify-end univer-gap-3",children:[jsx(Button,{onClick:()=>{e.hideEditPopup()},children:n.t("docLink.edit.cancel")}),jsx(Button,{variant:"primary",disabled:isBlankInput(d),onClick:m,children:n.t("docLink.edit.confirm")})]})]})};DocHyperLinkEdit.componentKey="docs-hyper-link-edit";const DeleteDocHyperLinkCommand={type:CommandType.COMMAND,id:"docs.command.delete-hyper-link",async handler(e,n){if(!n)return!1;const{unitId:i,linkId:t,segmentId:r}=n,o=e.get(ICommandService),d=deleteCustomRangeFactory(e,{unitId:i,rangeId:t,segmentId:r});return!!d&&await o.syncExecuteCommand(d.id,d.params)}},shouldDisableAddLink=e=>{const n=e.get(DocSelectionManagerService),i=e.get(IUniverInstanceService),t=n.getTextRanges();if(!(null==t?void 0:t.length))return!0;const r=t[0];return!(i.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC)&&r&&!r.collapsed)},ShowDocHyperLinkEditPopupOperation={type:CommandType.OPERATION,id:"doc.operation.show-hyper-link-edit-popup",handler(e,n){var i;const t=null==n?void 0:n.link,r=e.get(IUniverInstanceService);if(shouldDisableAddLink(e)&&!t)return!1;const o=e.get(DocHyperLinkPopupService),d=(null==t?void 0:t.unitId)||(null===(i=r.getCurrentUnitForType(UniverInstanceType.UNIVER_DOC))||void 0===i?void 0:i.getUnitId());return!!d&&(o.showEditPopup(d,t),!0)}},ToggleDocHyperLinkInfoPopupOperation={type:CommandType.OPERATION,id:"doc.operation.toggle-hyper-link-info-popup",handler(e,n){const i=e.get(DocHyperLinkPopupService);return n?(i.showInfoPopup(n),!0):(i.hideInfoPopup(),!0)}},ClickDocHyperLinkOperation={type:CommandType.OPERATION,id:"doc.operation.click-hyper-link",handler(e,n){var i;if(!n)return!1;const{unitId:t,linkId:r,segmentId:o}=n,d=e.get(IUniverInstanceService).getUnit(t,UniverInstanceType.UNIVER_DOC),c=null==d?void 0:d.getSelfOrHeaderFooterModel(o).getBody(),s=null==c||null===(i=c.customRanges)||void 0===i||null===(i=i.find((e=>e.rangeId===r&&e.rangeType===CustomRangeType.HYPERLINK)))||void 0===i||null===(i=i.properties)||void 0===i?void 0:i.url;return s&&window.open(s,"_blank","noopener noreferrer"),!0}},DocLinkPopup=()=>{var e,n;const i=useDependency(DocHyperLinkPopupService),t=useDependency(ICommandService),r=useDependency(IMessageService),o=useDependency(LocaleService),d=useObservable(i.showingLink$),c=useDependency(IUniverInstanceService);if(!d)return null;const{unitId:s,linkId:a,segmentId:l,startIndex:u,endIndex:p}=d,v=c.getUnit(s,UniverInstanceType.UNIVER_DOC),m=null==v?void 0:v.getSelfOrHeaderFooterModel(l).getBody(),I=null==m||null===(e=m.customRanges)||void 0===e?void 0:e.find((e=>e.rangeId===a&&e.rangeType===CustomRangeType.HYPERLINK&&e.startIndex===u&&e.endIndex===p));if(!I)return null;const g=null===(n=I.properties)||void 0===n?void 0:n.url;return jsxs("div",{className:clsx("univer-box-border univer-flex univer-max-w-80 univer-items-center univer-justify-between univer-overflow-hidden univer-rounded-lg univer-bg-white univer-p-3 univer-shadow dark:!univer-bg-gray-900",borderClassName),onClick:()=>{i.hideInfoPopup()},children:[jsxs("div",{className:"univer-flex univer-h-6 univer-flex-1 univer-cursor-pointer univer-items-center univer-truncate univer-text-sm univer-leading-5 univer-text-primary-500",onClick:()=>window.open(g,void 0,"noopener noreferrer"),children:[jsx("div",{className:"univer-mr-2 univer-flex univer-size-5 univer-flex-[0_0_auto] univer-items-center univer-justify-center univer-text-base univer-text-gray-900 dark:!univer-text-white",children:jsx(LinkIcon,{})}),jsx(Tooltip,{showIfEllipsis:!0,title:g,children:jsx("span",{className:"univer-flex-1 univer-truncate",children:g})})]}),jsxs("div",{className:"univer-flex univer-h-6 univer-flex-[0_0_auto] univer-items-center univer-justify-center",children:[jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",onClick:()=>{navigator.clipboard.writeText(g),r.show({content:o.t("docLink.info.coped"),type:MessageType.Info})},children:jsx(Tooltip,{placement:"bottom",title:o.t("docLink.info.copy"),children:jsx(CopyIcon,{})})}),jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",onClick:()=>{t.executeCommand(ShowDocHyperLinkEditPopupOperation.id,{link:d})},children:jsx(Tooltip,{placement:"bottom",title:o.t("docLink.info.edit"),children:jsx(WriteIcon,{})})}),jsx("div",{className:"univer-ml-2 univer-flex univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-base",onClick:()=>{t.executeCommand(DeleteDocHyperLinkCommand.id,{unitId:s,linkId:I.rangeId,segmentId:l})},children:jsx(Tooltip,{placement:"bottom",title:o.t("docLink.info.cancel"),children:jsx(UnlinkIcon,{})})})]})]})};function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function toPrimitive(e,n){if("object"!=_typeof(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var t=i.call(e,n||"default");if("object"!=_typeof(t))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}function toPropertyKey(e){var n=toPrimitive(e,"string");return"symbol"==_typeof(n)?n:n+""}function _defineProperty(e,n,i){return(n=toPropertyKey(n))in e?Object.defineProperty(e,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[n]=i,e}function __decorateParam(e,n){return function(i,t){n(i,t,e)}}function __decorate(e,n,i,t){var r,o=arguments.length,d=o<3?n:null===t?t=Object.getOwnPropertyDescriptor(n,i):t;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)d=Reflect.decorate(e,n,i,t);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(d=(o<3?r(d):o>3?r(n,i,d):r(n,i))||d);return o>3&&d&&Object.defineProperty(n,i,d),d}DocLinkPopup.componentKey="univer.doc.link-info-popup";let DocHyperLinkPopupService=class extends Disposable{constructor(e,n,i){super(),this._docCanvasPopupManagerService=e,this._textSelectionManagerService=n,this._univerInstanceService=i,_defineProperty(this,"_editingLink$",new BehaviorSubject(null)),_defineProperty(this,"_showingLink$",new BehaviorSubject(null)),_defineProperty(this,"editingLink$",this._editingLink$.asObservable()),_defineProperty(this,"showingLink$",this._showingLink$.asObservable()),_defineProperty(this,"_editPopup",null),_defineProperty(this,"_infoPopup",null),this.disposeWithMe((()=>{this._editingLink$.complete(),this._showingLink$.complete()}))}get editing(){return this._editingLink$.value}get showing(){return this._showingLink$.value}showEditPopup(e,n){this._editPopup&&this._editPopup.dispose(),this._editingLink$.next(n);const i=this._textSelectionManagerService.getTextRanges({unitId:e,subUnitId:e});let t=null==i?void 0:i[i.length-1];if(n){const{segmentId:e,segmentPage:i,startIndex:r,endIndex:o}=n;t={collapsed:!1,startOffset:r,endOffset:o+1,segmentId:e,segmentPage:i},this._textSelectionManagerService.replaceDocRanges([{startOffset:r,endOffset:o+1}])}return t?(this._editPopup=this._docCanvasPopupManagerService.attachPopupToRange(t,{componentKey:DocHyperLinkEdit.componentKey,direction:"bottom"},e),this._editPopup):null}hideEditPopup(){var e;this._editingLink$.next(null),null===(e=this._editPopup)||void 0===e||e.dispose()}showInfoPopup(e){var n,i,t,r,o,d;const{linkId:c,unitId:s,segmentId:a,segmentPage:l,startIndex:u,endIndex:p}=e;if(((null===(n=this.showing)||void 0===n?void 0:n.linkId)!==c||(null===(i=this.showing)||void 0===i?void 0:i.unitId)!==s||(null===(t=this.showing)||void 0===t?void 0:t.segmentId)!==a||(null===(r=this.showing)||void 0===r?void 0:r.segmentPage)!==l||(null===(o=this.showing)||void 0===o?void 0:o.startIndex)!==u||(null===(d=this.showing)||void 0===d?void 0:d.endIndex)!==p)&&(this._infoPopup&&this._infoPopup.dispose(),this._univerInstanceService.getUnit(s,UniverInstanceType.UNIVER_DOC)))return this._showingLink$.next({unitId:s,linkId:c,segmentId:a,segmentPage:l,startIndex:u,endIndex:p}),this._infoPopup=this._docCanvasPopupManagerService.attachPopupToRange({collapsed:!1,startOffset:u,endOffset:p+1,segmentId:a,segmentPage:l},{componentKey:DocLinkPopup.componentKey,direction:"top-center",multipleDirection:"top",onClickOutside:()=>{this.hideInfoPopup()}},s),this._infoPopup}hideInfoPopup(){var e;this._showingLink$.next(null),null===(e=this._infoPopup)||void 0===e||e.dispose()}};DocHyperLinkPopupService=__decorate([__decorateParam(0,Inject(DocCanvasPopManagerService)),__decorateParam(1,Inject(DocSelectionManagerService)),__decorateParam(2,IUniverInstanceService)],DocHyperLinkPopupService);let DocHyperLinkSelectionController=class extends Disposable{constructor(e,n,i){super(),this._commandService=e,this._univerInstanceService=n,this._docHyperLinkService=i,this._initSelectionChange()}_initSelectionChange(){this.disposeWithMe(this._commandService.onCommandExecuted((e=>{if(e.id===SetTextSelectionsOperation.id){const{unitId:t,ranges:r,segmentId:o}=e.params,d=this._univerInstanceService.getUnit(t,UniverInstanceType.UNIVER_DOC),c=r[0];if(c&&d){var n;const{startOffset:e,endOffset:r,collapsed:s,segmentPage:a}=c,l=null===(n=d.getSelfOrHeaderFooterModel(o))||void 0===n||null===(n=n.getBody())||void 0===n?void 0:n.customRanges;if(s){var i;const n=null!==(i=null==l?void 0:l.findIndex((n=>n.startIndex<e&&n.endIndex>r-1)))&&void 0!==i?i:-1;if(n>-1){const e=l[n];return void this._docHyperLinkService.showInfoPopup({unitId:t,linkId:e.rangeId,segmentId:o,segmentPage:a,startIndex:e.startIndex,endIndex:e.endIndex})}}else if(null==l?void 0:l.find((n=>n.startIndex<=e&&n.endIndex>=r-1)))return}this._docHyperLinkService.hideInfoPopup(),this._docHyperLinkService.hideEditPopup()}})))}};DocHyperLinkSelectionController=__decorate([__decorateParam(0,ICommandService),__decorateParam(1,IUniverInstanceService),__decorateParam(2,Inject(DocHyperLinkPopupService))],DocHyperLinkSelectionController);let DocHyperLinkEventRenderController=class extends Disposable{get _skeleton(){return this._docSkeletonManagerService.getSkeleton()}constructor(e,n,i,t,r,o){super(),this._context=e,this._docEventManagerService=n,this._commandService=i,this._hyperLinkPopupService=t,this._docSkeletonManagerService=r,this._docSelectionManagerService=o,this._context.unitId!==DOCS_ZEN_EDITOR_UNIT_ID_KEY&&this._context.unitId!==DOCS_NORMAL_EDITOR_UNIT_ID_KEY&&(this._initHover(),this._initClick())}_hideInfoPopup(){this._hyperLinkPopupService.showing&&this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id)}_initHover(){this.disposeWithMe(this._docEventManagerService.hoverCustomRanges$.subscribe((e=>{var n;const i=e.find((e=>e.range.rangeType===CustomRangeType.HYPERLINK)),t=this._docSelectionManagerService.getTextRanges(),r=null==t?void 0:t[0].segmentId;(null!==(n=null==i?void 0:i.segmentId)&&void 0!==n?n:"")===r&&i?this._commandService.executeCommand(ToggleDocHyperLinkInfoPopupOperation.id,{unitId:this._context.unitId,linkId:i.range.rangeId,segmentId:i.segmentId,segmentPage:i.segmentPageIndex,rangeId:i.range.rangeId,startIndex:i.range.startIndex,endIndex:i.range.endIndex}):this._hideInfoPopup()})))}_initClick(){this.disposeWithMe(this._docEventManagerService.clickCustomRanges$.subscribe((e=>{const n=e.range;n&&this._commandService.executeCommand(ClickDocHyperLinkOperation.id,{unitId:this._context.unitId,linkId:n.rangeId,segmentId:e.segmentId})})))}};DocHyperLinkEventRenderController=__decorate([__decorateParam(1,Inject(DocEventManagerService)),__decorateParam(2,ICommandService),__decorateParam(3,Inject(DocHyperLinkPopupService)),__decorateParam(4,Inject(DocSkeletonManagerService)),__decorateParam(5,Inject(DocSelectionManagerService))],DocHyperLinkEventRenderController);let DocHyperLinkRenderController=class extends Disposable{constructor(e,n,i,t){super(),this._context=e,this._docInterceptorService=n,this._hyperLinkService=i,this._docRenderController=t,this._init(),this._initReRender()}_init(){this._docInterceptorService.intercept(DOC_INTERCEPTOR_POINT.CUSTOM_RANGE,{handler:(e,n,i)=>{if(!e)return i(e);const{unitId:t,index:r}=n,o=this._hyperLinkService.showing;if(!o)return i({...e,active:!1});const{linkId:d,unitId:c,startIndex:s,endIndex:a}=o,l=c===t&&e.rangeId===d&&r>=s&&r<=a;return i({...e,active:l})}})}_initReRender(){this.disposeWithMe(this._hyperLinkService.showingLink$.pipe(distinctUntilChanged(((e,n)=>(null==e?void 0:e.linkId)===(null==n?void 0:n.linkId)&&(null==e?void 0:e.unitId)===(null==n?void 0:n.unitId)&&(null==e?void 0:e.startIndex)===(null==n?void 0:n.startIndex))),pairwise()).subscribe((([e,n])=>{n?n.unitId===this._context.unitId&&this._docRenderController.reRender(n.unitId):e&&e.unitId===this._context.unitId&&this._docRenderController.reRender(e.unitId)})))}};DocHyperLinkRenderController=__decorate([__decorateParam(1,Inject(DocInterceptorService)),__decorateParam(2,Inject(DocHyperLinkPopupService)),__decorateParam(3,Inject(DocRenderController))],DocHyperLinkRenderController);const DOC_LINK_ICON="doc-hyper-link-icon";function AddHyperLinkMenuItemFactory(e){return{id:ShowDocHyperLinkEditPopupOperation.id,type:MenuItemType.BUTTON,icon:DOC_LINK_ICON,title:"docLink.menu.tooltip",tooltip:"docLink.menu.tooltip",hidden$:getMenuHiddenObservable(e,UniverInstanceType.UNIVER_DOC),disabled$:new Observable((function(n){const i=e.get(DocSelectionManagerService).textSelection$.pipe(debounceTime(16)).subscribe((()=>{n.next(shouldDisableAddLink(e))}));return()=>{i.unsubscribe()}}))}}const addLinkShortcut={id:ShowDocHyperLinkEditPopupOperation.id,binding:MetaKeys.CTRL_COMMAND|KeyCode.K,description:"docLink.menu.tooltip",preconditions:whenDocAndEditorFocused},menuSchema={[RibbonInsertGroup.MEDIA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:1,menuItemFactory:AddHyperLinkMenuItemFactory}},[ContextMenuPosition.MAIN_AREA]:{[ContextMenuGroup.DATA]:{[ShowDocHyperLinkEditPopupOperation.id]:{order:0,menuItemFactory:AddHyperLinkMenuItemFactory}}}};let DocHyperLinkUIController=class extends Disposable{constructor(e,n,i,t){super(),this._componentManager=e,this._commandService=n,this._menuManagerService=i,this._shortcutService=t,this._initComponents(),this._initCommands(),this._initMenus(),this._initShortcut()}_initComponents(){[[DocHyperLinkEdit.componentKey,DocHyperLinkEdit],[DocLinkPopup.componentKey,DocLinkPopup],[DOC_LINK_ICON,LinkIcon]].forEach((([e,n])=>{this.disposeWithMe(this._componentManager.register(e,n))}))}_initCommands(){[AddDocHyperLinkCommand,UpdateDocHyperLinkCommand,DeleteDocHyperLinkCommand,ShowDocHyperLinkEditPopupOperation,ToggleDocHyperLinkInfoPopupOperation,ClickDocHyperLinkOperation].forEach((e=>{this._commandService.registerCommand(e)}))}_initShortcut(){[addLinkShortcut].forEach((e=>{this._shortcutService.registerShortcut(e)}))}_initMenus(){this._menuManagerService.mergeMenu(menuSchema)}};DocHyperLinkUIController=__decorate([__decorateParam(0,Inject(ComponentManager)),__decorateParam(1,ICommandService),__decorateParam(2,IMenuManagerService),__decorateParam(3,IShortcutService)],DocHyperLinkUIController);const DOC_HYPER_LINK_UI_PLUGIN="DOC_HYPER_LINK_UI_PLUGIN";let UniverDocsHyperLinkUIPlugin=class extends Plugin{constructor(e=defaultPluginConfig,n,i,t){super(),this._config=e,this._injector=n,this._renderManagerSrv=i,this._configService=t;const{menu:r,...o}=merge({},defaultPluginConfig,this._config);r&&this._configService.setConfig("menu",r,{merge:!0}),this._configService.setConfig("docs-hyper-link-ui.config",o)}onStarting(){[[DocHyperLinkPopupService],[DocHyperLinkUIController],[DocHyperLinkSelectionController]].forEach((e=>{this._injector.add(e)})),this._injector.get(DocHyperLinkUIController)}onReady(){this._injector.get(DocHyperLinkSelectionController)}onRendered(){this._initRenderModule()}_initRenderModule(){[[DocHyperLinkRenderController],[DocHyperLinkEventRenderController]].forEach((e=>{this._renderManagerSrv.registerRenderModule(UniverInstanceType.UNIVER_DOC,e)}))}};_defineProperty(UniverDocsHyperLinkUIPlugin,"pluginName",DOC_HYPER_LINK_UI_PLUGIN),_defineProperty(UniverDocsHyperLinkUIPlugin,"packageName",name),_defineProperty(UniverDocsHyperLinkUIPlugin,"version",version),_defineProperty(UniverDocsHyperLinkUIPlugin,"type",UniverInstanceType.UNIVER_DOC),UniverDocsHyperLinkUIPlugin=__decorate([DependentOn(UniverDocsHyperLinkPlugin),__decorateParam(1,Inject(Injector)),__decorateParam(2,IRenderManagerService),__decorateParam(3,IConfigService)],UniverDocsHyperLinkUIPlugin);export{UniverDocsHyperLinkUIPlugin};
//# sourceMappingURL=/sm/aa9471440114f5ed08fc6f798cfa8695d7d32fe661450fbbef232fe0f431b71f.map