"use strict";(self.webpackChunkapp=self.webpackChunkapp||[]).push([[14023],{14023:(e,t,r)=>{r.r(t),r.d(t,{AddonModWikiCreateLinkHandler:()=>y,AddonModWikiCreateLinkHandlerLazyService:()=>k});var i=r(10467),a=r(44682),n=r(15324),d=r(79555),o=r(67981),s=r(51069),c=r(93320),u=r(33014),l=r(25572),g=r(54438);let k=(()=>{var e;class AddonModWikiCreateLinkHandlerLazyService extends c.g{currentStateIsSameWiki(e,t,r){return(0,i.A)((function*(){if(!e)return!1;const i=n.CoreNavigator.getRouteParams(e),a=n.CoreNavigator.getRouteQueryParams(e);if(a.subwikiId==t)return!0;const d={cmId:i.cmId,readingStrategy:1,siteId:r};if(a.pageId)try{return(yield o.N.getPageContents(a.pageId,d)).subwikiid==t}catch{}try{const e=yield o.N.getWiki(i.courseId,i.cmId,d);return yield o.N.wikiHasSubwiki(e.id,t,d)}catch{return!1}}))()}handleAction(e,t,o){var c=this;return(0,i.A)((function*(){const i=yield u.CoreLoadings.show(),g=yield Promise.all([r.e(98054),r.e(89752),r.e(51024),r.e(36549),r.e(84078),r.e(72076)]).then(r.bind(r,49072));try{const r=n.CoreNavigator.getCurrentRoute({pageComponent:g.default});if(!r)return;const i=parseInt(o.swid,10),d=parseInt(o.wid,10);let u=s.Jb;if(yield c.currentStateIsSameWiki(r,i,e)){const e=n.CoreNavigator.getRouteParams(r);u=`${u}/${e.courseId}/${e.cmId}/edit`}else if(d){const t=yield a.CoreCourse.getModuleBasicInfoByInstance(d,s.Pe,{siteId:e,readingStrategy:1});u=`${u}/${t.course}/${t.id}/edit`}else u=`${u}/${t||0}/0/edit`;n.CoreNavigator.navigateToSitePath(u,{params:{pageTitle:o.title,subwikiId:i},siteId:e})}catch(e){l.CoreAlerts.showError(e,{default:d.HT.instant("addon.mod_wiki.errorloadingpage")})}finally{i.dismiss()}}))()}}return(e=AddonModWikiCreateLinkHandlerLazyService).ɵfac=(()=>{let t;return function AddonModWikiCreateLinkHandlerLazyService_Factory(r){return(t||(t=g.xGo(e)))(r||e)}})(),e.ɵprov=g.jDH({token:e,factory:e.ɵfac,providedIn:"root"}),AddonModWikiCreateLinkHandlerLazyService})();const y=(0,d.Qd)(k)}}]);