/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
*/
"use strict";var Tn=Object.defineProperty;var Co=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var Fo=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var n in t)Tn(e,n,{get:t[n],enumerable:!0})},Mo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of So(t))!Fo.call(e,i)&&i!==n&&Tn(e,i,{get:()=>t[i],enumerable:!(r=Co(t,i))||r.enumerable});return e};var vo=e=>Mo(Tn({},"__esModule",{value:!0}),e);var wl={};Qe(wl,{default:()=>vl});module.exports=vo(wl);var yo=require("obsidian");function B(e,t){return`${e}:${t}`}function An(e){return e?.cardType==="basic"}function ti(e){return e?.cardType==="cloze"}function O(e){return e?.cardType==="qa-group"}var ni=require("obsidian");function se(e=(0,ni.getLanguage)()){let t=e.toLowerCase();return t==="zh"||t.startsWith("zh-")?"zh":"en"}function de(e,t){return t.join(e==="zh"?"\u3001":", ")}var En={commands:{syncCurrentFileToAnki:"Sync current file to Anki",syncVaultToAnki:"Sync vault to Anki",clearCurrentFileSyncedCards:"Clear synced cards in current file",cleanupEmptyDecks:"Clean up empty decks"},settings:{pluginTitle:"Anki heading sync",ankiConnectUrl:{name:"AnkiConnect URL",desc:"Default: http://127.0.0.1:8765",placeholder:"Example: http://127.0.0.1:8765"},qaHeadingLevel:{name:"Heading level for question-and-answer cards",desc:"Default question-and-answer heading level is 4."},clozeHeadingLevel:{name:"Cloze heading level",desc:"Default cloze heading level is 5."},cardAnswerCutoffMode:{name:"Card answer cutoff mode",desc:"A valid sync marker always wins. Without a valid marker, either keep the whole heading block or stop before the first 2+ consecutive blank lines.",options:{headingBlock:"Heading-block: whole heading block",doubleBlankLines:"Double-blank-lines: stop before the first 2+ blank lines"}},qaGroup:{title:"List notes for question-and-answer groups",marker:{name:"Marker for question-and-answer groups",desc:"When a question-and-answer heading ends with this hashtag marker, the whole heading block syncs as one list note for that group.",placeholder:"Hashtag marker"},managedNoteType:"Current note type: {{modelName}}. This route syncs QA Group list notes using the field mapping shown below.",managedModelContract:"Current note type summary: {{fieldCount}} fields and {{templateCount}} templates are available for this route."},syncOptions:{addObsidianBacklink:{name:"Add Obsidian backlink",desc:"Append a backlink to the source heading into synced cards."},obsidianBacklinkLabel:{name:"Obsidian backlink label",desc:"The text shown for the backlink. Blank input uses the default backlink label.",placeholder:"Open in Obsidian"},obsidianBacklinkPlacement:{name:"Obsidian backlink placement",desc:"Choose whether the backlink is appended to the question field or placed at the start or end of the answer body.",options:{questionLastLine:"Last line of question field",answerFirstLine:"First line of answer body",answerLastLine:"Last line of answer body"}},highlightsToCloze:{name:"Highlights to cloze",desc:"Convert ==highlight== segments into cloze deletions for cloze cards."},syncObsidianTagsToAnki:{name:"Sync Obsidian tags to Anki",desc:"Sync Obsidian-recognized tags from the current note into Anki note tags, including nested tags. On each sync, these tags overwrite the managed tags in Anki based on the current Obsidian content."},keepPureTagLinesInCardBody:{name:"Keep pure tag lines in card body",desc:'When turned off, remove every line in the card body that contains only tags, such as "#example #tag/case". Inline tags like "this is a #tag example" and lines with ordinary text like "tag label: #project" are kept. Extra blank lines created by removal are cleaned up automatically.'}},mapping:{title:"Note type field mappings",refresh:{name:"Refresh note types from Anki",button:"Refresh note types"},status:{idle:"Refresh note types from Anki to load the available note types.",loadedCount:"Loaded {{count}} note types from Anki.",empty:"Anki returned no note types.",failedLoadNoteTypes:"Failed to load note types from Anki.",loadedSavedMapping:"Loaded saved mapping for {{modelName}}.",selectedModel:"Selected {{modelName}}. Read fields from Anki to create or refresh its mapping.",loadedFieldsForModel:"Loaded fields for {{modelName}}. Review the suggested mapping and save it.",failedLoadFields:"Failed to load fields for {{modelName}}.",noLoadedFields:"No loaded fields for {{modelName}}. Read fields from Anki first.",savedMapping:"Saved mapping for {{modelName}}.",failedSaveMapping:"Failed to save mapping for {{modelName}}.",savedMappingReady:"Saved mapping is ready for {{title}}.",noSavedMapping:"No saved mapping for {{title}}. Read fields from Anki first."},section:{basic:{title:"Basic and question-and-answer",description:"Choose the note type for question-and-answer cards, read its fields from Anki, then confirm the title and body mapping."},cloze:{title:"Cloze",description:"Choose the cloze note type, read its fields from Anki, then confirm the main field mapping."}},noteTypeLabel:"{{title}} note type",noteTypeDesc:"Loaded from Anki note types. Refresh if the latest models are not shown.",fieldsLabel:"{{title}} fields",fieldsDesc:"Load the current note type fields from Anki, then review the suggested mapping.",readFieldsButton:"Read fields from Anki",loadedFields:"Loaded fields: {{fields}}",loadedFieldsNone:"Loaded fields: none. Read fields from Anki first.",mappingLabel:"{{title}} mapping",mappingDesc:"Save the current field mapping for this specific note type.",saveMappingButton:"Save mapping",titleFieldLabel:"{{title}} title field",titleFieldDesc:"Which Anki field should receive the heading/title fragment.",bodyFieldLabel:"{{title}} body field",bodyFieldDesc:"Which Anki field should receive the body fragment.",mainField:{name:"Cloze main field",desc:"The selected field receives title +
=p))){a=o===61?1:2;break}}if(e.sCount[u]<0)continue;let f=!1;for(let m=0,p=r.length;m
3||e.sCount[a]<0)continue;let d=!1;for(let c=0,l=r.length;c ${t} ]*>.*?<\/a><\/p>/g,"").replace(/ne((2147483647-i)/d)&&ke("overflow"),i+=(s-r)*d,r=s;for(let c of e)if(c
${t}`:t,body:e.body};let r=`
]*>.*?<\/a>/g,"").trim()}function cl(e){return e.includes("GroupId")&&e.includes("Src")&&e.some(n=>/^S\d+_Id$/i.test(n))&&e.some(n=>/^S\d+_Q$/i.test(n))&&e.some(n=>/^S\d+_A$/i.test(n))?e.filter(n=>n==="GroupId"||n==="Src"||/^S\d+_Id$/i.test(n)):[]}function ll(e){let t=[];return{text:e.replace(Xc,r=>{let i=`@@QA_GROUP_INLINE_CODE_${t.length}@@`;return t.push(r),i}),restore:r=>t.reduce((i,a,o)=>i.split(`@@QA_GROUP_INLINE_CODE_${o}@@`).join(a),r)}}var pl="manual-render-v3",Ae=class{constructor(t=new Oe){this.deckResolutionService=t}resolve(t,n){let r=fl(t.cardType,n),i=this.deckResolutionService.resolve(t,n),a=i.resolvedDeck.value,o=n.noteFieldMappings[B(t.cardType,r)]??null,u=t.cardType==="cloze"&&t.clozeMode==="all"?"all":void 0,s={version:pl,cardType:t.cardType,clozeMode:u,noteModel:r,mapping:o,addObsidianBacklink:n.addObsidianBacklink,obsidianBacklinkLabel:n.obsidianBacklinkLabel,obsidianBacklinkPlacement:n.obsidianBacklinkPlacement,convertHighlightsToCloze:n.convertHighlightsToCloze,keepPureTagLinesInCardBody:n.keepPureTagLinesInCardBody},d=Q(JSON.stringify(s));return{deck:a,noteModel:r,renderConfigHash:d,warnings:i.warnings}}};function fl(e,t){if(Ei(e)){if(!t.clozeNoteType.trim())throw new S("errors.noteFieldMapping.noteTypeNotSelected.cloze");return t.clozeNoteType}if(!t.qaNoteType.trim())throw new S("errors.noteFieldMapping.noteTypeNotSelected.basic");return t.qaNoteType}var Yr=/`[^`\n]+`/g,Xr=/```[\s\S]*?```|~~~[\s\S]*?~~~/g,Fn=/==(.+?)==/g,Jr=/(?:(?0&&i.add(u)}for(let o of r.text.matchAll(Jr)){let u=o[1],s=u?Number(u):e.clozeMode==="all"?1:a++;Number.isInteger(s)&&s>0&&i.add(s)}return i}function $e(e,t,n){let r=[];return{text:e.replace(t,a=>{let o=`@@${n}_${r.length}@@`;return r.push(a),o}),restore:(a,o=u=>u)=>r.reduce((u,s,d)=>u.split(`@@${n}_${d}@@`).join(o(s)),a)}}var Mn=class{constructor(t=new Ae){this.renderConfigService=t}plan(t,n,r,i){let a=new Map,o=new Set(n.pendingWriteBack.filter(x=>x.markerKind!=="group-gi").map(x=>Ie(x.filePath,x.blockStartLine,x.rawBlockHash))),u=new Set,s=[],d=[],c=[],l=[],f=[],m=[],p=new Map,F=0;for(let x of t){if(a.has(x.syncKey))throw new Error(`Duplicate syncKey detected in current scan: ${x.syncKey}`);if(a.set(x.syncKey,x),x.noteId!==void 0){let R=H(x.noteId);if(u.has(R))throw new Error(`Duplicate noteId detected in current scan: ${x.noteId}`);u.add(R)}let C=x.noteId!==void 0?n.cards[H(x.noteId)]:void 0,h=this.renderConfigService.resolve(x,i);for(let R of h.warnings)p.set(We(R),R);let M=x.noteId,D=Ie(x.filePath,x.blockStartLine,x.rawBlockHash),T={card:{...x,noteId:M},noteId:M,deck:h.deck,noteModel:h.noteModel,renderConfigHash:h.renderConfigHash};if(!M){s.push(T);continue}if(ml(C,x,i)){d.push(T);continue}if(l.push(T),(x.idMarkerState!=="present-valid"||x.noteIdSource!=="marker"||o.has(D))&&m.push(T),!C){c.push(T);continue}let I=C.rawBlockHash!==x.rawBlockHash||C.renderConfigHash!==h.renderConfigHash||!Ki(C.tagsHint,x.tagsHint)||C.orphan,A=C.deck!==h.deck;I&&c.push(T),A&&f.push(T),!I&&!A&&(F+=1)}let k=new Set(r),b=Object.values(n.cards).filter(x=>k.has(x.filePath)&&!u.has(H(x.noteId)));return{toCreate:s,toRebuild:d,toUpdate:c,toVerifyDeck:l,toChangeDeck:f,toRewriteMarker:m,toOrphan:b,unchangedCards:F,warnings:Array.from(p.values())}}};function ml(e,t,n){if(!e||e.cardType!=="cloze"||t.cardType!=="cloze")return!1;let r=Se(e.cardType,e.clozeMode);if(r!=="sequential"||t.clozeMode!=="all")return!1;let i=ei({bodyMarkdown:e.bodyMarkdown,clozeMode:r,convertHighlightsToCloze:n.convertHighlightsToCloze}),a=ei({bodyMarkdown:t.bodyMarkdown,clozeMode:t.clozeMode,convertHighlightsToCloze:n.convertHighlightsToCloze});return i.size>a.size}var bo=new ot({breaks:!0,html:!0,linkify:!0}),hl=/(?`\\[${k.trim()}\\]`),d=d.replace(kl,(F,k)=>`\\(${k.trim()}\\)`),i&&r.convertHighlightsToCloze&&(d=d.replace(Fn,"{$1}")),i&&(d=d.replace(Jr,(F,k,b)=>`{{c${k?Number(k):n.card.clozeMode==="all"?1:l++}::${b}}}`)),d=d.replace(yl,(F,k)=>{let b=r.resourceResolver.resolveEmbed(k,n.card.filePath);return b?(c.push({kind:b.kind,fileName:b.fileName,absolutePath:b.absolutePath,altText:b.altText}),b.kind==="audio"?`[sound:${b.fileName}]`:``):F}),d=d.replace(xl,(F,k)=>{let b=r.resourceResolver.resolveWikiLink(k,n.card.filePath);return b?`${st(b.displayText)}`:F}),d=d.replace(Fn,"$1");let f=$e(d,bl,"MATH");d=f.text,d=s.restore(d),d=u.restore(d);let m=(a?bo.renderInline(d):bo.render(d)).trim(),p=f.restore(m,st);return{html:a?p:yn(p),media:c}}};function Cl(e){let t=new Set;return e.filter(n=>{let r=`${n.kind}:${n.absolutePath}:${n.fileName}`;return t.has(r)?!1:(t.add(r),!0)})}function st(e){return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}var dt=class extends S{constructor(t){super("errors.currentFileOutOfScope",{filePath:t}),this.name="CurrentFileOutOfScopeError"}},Ue=class extends S{constructor(){super("errors.runScopeNotConfigured"),this.name="RunScopeNotConfiguredError"}},wn=class{constructor(t,n,r,i=new Yt(t),a=new Mn,o=new vn,u=new Wt(r),s=new Xt(t),d=new Ae,c=()=>Date.now()){this.vaultGateway=t;this.pluginStateRepository=n;this.ankiGateway=r;this.fileIndexerService=i;this.diffPlannerService=a;this.renderer=o;this.ankiBatchExecutor=u;this.markdownWriteBackService=s;this.scanScopeService=new Pe;if(this.qaGroupSyncService=new Sn(r,void 0,void 0,void 0,void 0,void 0,void 0,this.vaultGateway.createBacklink.bind(this.vaultGateway)),Sl(d)){this.renderConfigService=d,this.now=c;return}this.renderConfigService=new Ae,this.now=d}async syncVault(t){pe(t),this.assertRunScopeConfigured(t);let n=await this.pluginStateRepository.load(),r=await this.fileIndexerService.indexVault(t,n);return this.syncIndexedResult(r,n,t)}async syncFile(t,n){if(pe(n),this.assertRunScopeConfigured(n),!this.scanScopeService.isPathInScope(t,n.scopeMode,n.includeFolders,n.excludeFolders))throw new dt(t);let r=await this.pluginStateRepository.load(),i=await this.fileIndexerService.indexFile(t,n,r);return this.syncIndexedResult(i,r,n)}assertRunScopeConfigured(t){if(!mt(t.scopeMode,t.includeFolders))throw new Ue}async syncIndexedResult(t,n,r){let i=this.diffPlannerService.plan(t.cards,n,t.scopedFilePaths,r),a={addObsidianBacklink:r.addObsidianBacklink,obsidianBacklinkLabel:r.obsidianBacklinkLabel,obsidianBacklinkPlacement:r.obsidianBacklinkPlacement,convertHighlightsToCloze:r.convertHighlightsToCloze,keepPureTagLinesInCardBody:r.keepPureTagLinesInCardBody,resourceResolver:this.vaultGateway},o=new Map;for(let m of[...i.toCreate,...i.toRebuild,...i.toUpdate])o.has(m.card.syncKey)||o.set(m.card.syncKey,this.renderer.render(m,a));let u=await this.ankiBatchExecutor.execute(i,o,m=>Promise.resolve(this.renderer.render(m,a)),r.noteFieldMappings),s=await this.qaGroupSyncService.sync(t.groupBlocks,n,r),d=new Map(t.indexedFiles.map(m=>[m.filePath,m])),c=await this.markdownWriteBackService.write(u.markerWrites,d,s.markerWrites),l=Fl(n,t.scopedFilePaths,s.syncedGroupBlocks),f=this.buildNextState(n,t.cards,t.indexedFiles,s.syncedGroupBlocks,r,new Set([...u.touchedSyncKeys,...s.touchedSyncKeys,...c.writtenSyncKeys]),u.resolvedNoteIds,i.toOrphan,l);if(f.pendingWriteBack=[...n.pendingWriteBack.filter(m=>!new Set(t.scopedFilePaths).has(m.filePath)),...c.pendingEntries],this.markFilesDirty(f,[...c.failureFiles.map(m=>m.filePath),...c.conflictFiles]),await this.pluginStateRepository.save(f),c.failureFiles.length>0)throw this.createWriteBackFailureError(c.failureFiles);return{scannedFiles:t.scannedFiles,scannedCards:t.cards.length+t.groupBlocks.length,created:u.created+s.created,rebuilt:u.rebuilt,updated:u.updated+s.updated,migratedNoteTypes:u.migratedNoteTypes+s.migratedNoteTypes,migratedDecks:u.migratedDecks+s.migratedDecks,orphaned:i.toOrphan.length+l.length,uploadedMedia:u.uploadedMedia,skippedUnchangedCards:t.skippedUnchangedCards,rewrittenMarkers:c.writtenSyncKeys.length,markerWriteConflictFiles:c.conflictFiles,warnings:Ml(i.warnings,s.warnings)}}buildNextState(t,n,r,i,a,o,u,s,d){let c=this.now(),l=Qn(a),f=new Set(r.filter(k=>k.content!==void 0).map(k=>k.filePath)),m=new Map;for(let k of i){let b=m.get(k.filePath);b?b.push(k):m.set(k.filePath,[k])}let p={files:{...t.files},cards:{...t.cards},groupBlocks:{...t.groupBlocks??{}},pendingWriteBack:[...t.pendingWriteBack]};for(let k of f)delete p.files[k];for(let[k,b]of Object.entries(p.cards))f.has(b.filePath)&&delete p.cards[k];for(let[k,b]of Object.entries(p.groupBlocks??{}))f.has(b.filePath)&&delete p.groupBlocks?.[k];let F=new Map;for(let k of n){let b=u.get(k.syncKey)??k.noteId;b!==void 0&&F.set(k.syncKey,b)}for(let k of r){if(k.content===void 0)continue;let b=Array.from(new Set(k.cards.map(x=>F.get(x.syncKey)).filter(x=>x!==void 0)));p.files[k.filePath]={filePath:k.filePath,fileHash:k.fileHash,fileStamp:k.fileStamp,deckRulesFingerprint:l,lastIndexedAt:c,noteIds:b,groupIds:(m.get(k.filePath)??[]).map(x=>x.groupId)}}for(let k of n){let b=F.get(k.syncKey);if(b===void 0)continue;let x=t.cards[H(b)]??(k.noteId!==void 0?t.cards[H(k.noteId)]:void 0),C=this.renderConfigService.resolve(k,a);p.cards[H(b)]={noteId:b,filePath:k.filePath,heading:k.heading,backlinkHeadingText:k.backlinkHeadingText,headingLevel:k.headingLevel,bodyMarkdown:k.bodyMarkdown,cardType:k.cardType,clozeMode:k.clozeMode,blockStartOffset:k.blockStartOffset,blockEndOffset:k.blockEndOffset,blockStartLine:k.blockStartLine,bodyStartLine:k.bodyStartLine,blockEndLine:k.blockEndLine,contentEndLine:k.contentEndLine,markerLine:k.markerLine,rawBlockText:k.rawBlockText,rawBlockHash:k.rawBlockHash,renderConfigHash:C.renderConfigHash,deck:C.deck,deckHint:k.deckHint,deckHintSource:k.deckHintSource,deckWarnings:[...k.deckWarnings],tagsHint:k.tagsHint,lastSyncedAt:o.has(k.syncKey)?c:x?.lastSyncedAt??0,orphan:!1}}for(let k of s)p.cards[H(k.noteId)]={...k,orphan:!0};for(let k of i)p.groupBlocks??(p.groupBlocks={}),p.groupBlocks[k.groupId]=k;for(let k of d)p.groupBlocks??(p.groupBlocks={}),p.groupBlocks[k.groupId]={...k,orphan:!0};return p}markFilesDirty(t,n){for(let r of new Set(n))t.files[r]&&(t.files[r]={...t.files[r],fileHash:"",fileStamp:""})}createWriteBackFailureError(t){return new S("errors.writeBack.summary",{fileCount:t.length},{failures:t})}};function Sl(e){return typeof e=="object"&&e!==null&&"resolve"in e}function Fl(e,t,n){let r=new Set(t),i=new Set(n.map(a=>a.groupId));return Object.values(e.groupBlocks??{}).filter(a=>r.has(a.filePath)&&!i.has(a.groupId)).map(a=>({...a,orphan:!0}))}function Ml(...e){let t=new Map;for(let n of e)for(let r of n)t.set(We(r),r);return[...t.values()]}var ct=class extends yo.Plugin{constructor(){super(...arguments);this.settings=z;this.noticeService=new Pt;this.ankiGateway=new wt(()=>this.settings.ankiConnectUrl);this.deckTemplateInsertionService=new ht}async onload(){let n=new Dt(this);this.pluginConfigRepository=new _t(n);let r=new It(n),i=new Et(this.app);this.vaultGateway=i;try{this.settings=await this.pluginConfigRepository.load()}catch(o){console.error("Failed to load plugin settings, falling back to defaults.",o),this.settings=z,this.noticeService.error(g("notice.invalidSettingsRestored"))}let a=new wn(i,r,this.ankiGateway);this.syncCurrentFileUseCase=new Mt(a),this.syncVaultUseCase=new vt(a),this.clearCurrentFileSyncedCardsUseCase=new Ft(r,this.ankiGateway,i),this.cleanupEmptyDecksUseCase=new kt(this.ankiGateway),Ai(this),this.addSettingTab(new qt(this))}async updateSettings(n){if(!this.pluginConfigRepository)return;let r=Ce({...this.settings,...n});try{await this.pluginConfigRepository.save(r),this.settings=r}catch(i){this.noticeService.error(xe(i,"notice.failedSavePluginSettings"))}}async listNoteModels(){return this.ankiGateway.listNoteModels()}async getModelFieldNamesByModelNames(n){return this.ankiGateway.getModelFieldNamesByModelNames(n)}async getNoteModelDetails(n){return this.ankiGateway.getModelDetails(n)}async listFolderTree(){return this.vaultGateway?this.vaultGateway.listFolderTree():[]}async runSyncCurrentFile(){let n=this.app.workspace.getActiveFile();if(!n||n.extension.toLowerCase()!=="md"){this.noticeService.error(g("notice.noActiveMarkdownForSync"));return}if(!this.syncCurrentFileUseCase){this.noticeService.error(g("notice.syncUseCaseNotInitialized"));return}try{let r=await this.syncCurrentFileUseCase.execute(n.path,this.settings);this.noticeService.showSyncSummary("currentFile",r)}catch(r){if(r instanceof dt||r instanceof Ue){this.noticeService.info(lt(r));return}console.error("Current file sync failed.",r),this.noticeService.error(xe(r,"notice.currentFileSyncFailed"))}}async runSyncVault(){if(!this.syncVaultUseCase){this.noticeService.error(g("notice.syncUseCaseNotInitialized"));return}try{let n=await this.syncVaultUseCase.execute(this.settings);this.noticeService.showSyncSummary("vault",n)}catch(n){if(n instanceof Ue){this.noticeService.info(lt(n));return}console.error("Vault sync failed.",n),this.noticeService.error(xe(n,"notice.vaultSyncFailed"))}}async insertDeckTemplateToCurrentFile(){let n=this.app.workspace.getActiveFile();if(!n||n.extension.toLowerCase()!=="md"){this.noticeService.error(g("notice.noActiveMarkdownForDeckTemplateInsertion"));return}if(!this.vaultGateway){this.noticeService.error(g("notice.vaultGatewayNotInitialized"));return}try{let r=await this.vaultGateway.readMarkdownFile(n.path);if(!r){this.noticeService.error(g("notice.markdownFileNotFound",{filePath:n.path}));return}let i=this.deckTemplateInsertionService.insert(r,this.settings.fileDeckMarker,this.settings.fileDeckTemplate,this.settings.fileDeckInsertLocation);if(i.nextContent===i.expectedContent){this.noticeService.info(g("notice.deckTemplateAlreadyCurrent"));return}await this.vaultGateway.replaceMarkdownFile(n.path,i.expectedContent,i.nextContent),this.noticeService.info(g("notice.deckTemplateInserted",{deck:i.insertedDeck}))}catch(r){console.error("Deck template insertion failed.",r),this.noticeService.error(xe(r,"notice.deckTemplateInsertionFailed"))}}async runClearCurrentFileSyncedCards(){let n=this.app.workspace.getActiveFile();if(!n||n.extension.toLowerCase()!=="md"){this.noticeService.error(g("notice.noActiveMarkdownForReset"));return}if(!this.clearCurrentFileSyncedCardsUseCase){this.noticeService.error(g("notice.clearCurrentFileUseCaseNotInitialized"));return}try{if(!await this.clearCurrentFileSyncedCardsUseCase.hasTrackedCards(n.path)){this.noticeService.info(g("notice.noTrackedCardsInCurrentFile"));return}let i=await this.clearCurrentFileSyncedCardsUseCase.execute(n.path);this.noticeService.showClearCurrentFileSummary(i)}catch(r){console.error("Clear current file synced cards failed.",r),this.noticeService.error(xe(r,"notice.clearCurrentFileFailed"))}}async runCleanupEmptyDecks(){if(!this.cleanupEmptyDecksUseCase){this.noticeService.error(g("notice.cleanupEmptyDecksUseCaseNotInitialized"));return}try{let n=await this.cleanupEmptyDecksUseCase.listCandidates();if(n.length===0){this.noticeService.info(g("notice.noEmptyDeckCandidates"));return}let r=await new Nt(this.app,n).openAndGetSelection();if(r===null){this.noticeService.info(g("notice.cleanupEmptyDecksCancelled"));return}let i=await this.cleanupEmptyDecksUseCase.execute(r,n);this.noticeService.showCleanupEmptyDecksSummary(i)}catch(n){console.error("Cleanup empty decks failed.",n),this.noticeService.error(xe(n,"notice.cleanupEmptyDecksFailed"))}}};var vl=ct;