varF=Object.defineProperty;varae=Object.getOwnPropertyDescriptor;varre=Object.getOwnPropertyNames;varoe=Object.prototype.hasOwnProperty;varle=(a,r)=>{for(vareinr)F(a,e,{get:r[e],enumerable:!0})},ce=(a,r,e,t)=>{if(r&&typeofr=="object"||typeofr=="function")for(letiofre(r))!oe.call(a,i)&&i!==e&&F(a,i,{get:()=>r[i],enumerable:!(t=ae(r,i))||t.enumerable});returna};varde=a=>ce(F({},"__esModule",{value:!0}),a);varIe={};le(Ie,{default:()=>R});module.exports=de(Ie);varp=require("obsidian");functionk(a,r){return`${a}::${r}`}functionB(a,r,e,t){leti=[];returna.forEach((n,s)=>{n.filePath===r&&i.push([s,{...n,filePath:e,remoteName:n.remoteName||t(r),deletedLocal:!1}])}),i.forEach(([n,s])=>{a.delete(n),a.set(k(s.datasetId,e),s)}),i.length>0}functionH(a,r,e,t,i,n=newDate,s=3e4){leto=k(r,e);if(a.has(o))return!1;letl,c,d=-1;returna.forEach((u,h)=>{if(u.datasetId!==r||u.filePath===e||!u.documentId||!u.deletedLocal||u.hash!==t)return;letg=Date.parse(u.lastSyncedAt);if(!Number.isFinite(g))return;lety=n.getTime()-g;y<0||y>s||g<=d||(l=h,c=u,d=g)}),!l||!c?!1:(a.delete(l),a.set(o,{...c,filePath:e,remoteName:c.remoteName||i(c.filePath),deletedLocal:!1}),!0)}varY=require("obsidian");functionV(a,r=""){lete=P(a,r),t=j(a);if(!t)thrownewError(W(e));returnt.filter(i=>!!(i!=null&&i.id)).map(i=>({id:i.id,name:i.name||i.id,description:i.description}))}functionz(a,r=""){if(!j(a))thrownewError(W(P(a,r)))}functionP(a,r=""){lete=/^\s*</.test(r||""),t=Array.isArray(a)?"array":a===null?"null":typeofa,i=Q(a)?a:void0,n=i==null?void0:i.data;return{topLevelType:t,topLevelKeys:i?Object.keys(i).slice(0,12):[],dataIsArray:Array.isArray(n),dataLength:Array.isArray(n)?n.length:void0,looksLikeHtml:e}}functionj(a){returnArray.isArray(a)?a:Q(a)&&Array.isArray(a.data)?a.data:null}functionW(a){letr=a.looksLikeHtml?"received an HTML page":`top-level type ${a.topLevelType}`,e=a.topLevelKeys.length>0?`; top-level fields: ${a.topLevelKeys.join(", ")}`:"";return`Current address did not return a Dify knowledge base API response (${r}${e}).`}functionQ(a){returntypeofa=="object"&&a!==null&&!Array.isArray(a)}functionb(a){letr=(a||"").trim().replace(/\/+$/,"").replace(/\/v1\/datasets$/i,"").replace(/\/v1$/i,"");returnr?/^https?:\/\//i.test(r)?r:`http://${r}`:""}functionM(a){return(a||"").trim().replace(/^\/+|\/+$/g,"")}functionpe(a,r){lete=M(r);returne===""?!0:e.toLowerCase().endsWith(".md")?a===e:a===e||a.startsWith(`${e}/`)}functionA(a){if(!a)return{};try{returnJSON.parse(a)}catch(r){return{}}}functionf(a){returntypeofa=="object"&&a!==null&&!Array.isArray(a)}functionS(a,r){lete=a[r];returntypeofe=="string"?e:void0}functionC(a,r){lete=a[r];returntypeofe=="number"?e:void0}functionD(a){returnArray.from(newSet(a.map(r=>r.trim()).filter(Boolean)))}functionG(a,r){lete=[];returnr.filter(t=>t.enabled&&Array.isArray(t.datasetIds)&&t.datasetIds.length>0).forEach(t=>{pe(a,t.folder)&&e.push(...t.datasetIds)}),D(e)}functionJ(a,r){returna.filter(e=>e.id!==r)}functionv(a,r,e,t){leti=Number(a);returnNumber.isFinite(i)?Math.min(e,Math.max(r,i)):t}varm=classextendsError{constructor(e,t,i,n){super(e);this.name="DifyApiError",this.status=t,this.responseText=i,this.reason=n,Object.setPrototypeOf(this,m.prototype)}getisTransient(){return!this.status||this.status===408||this.status===429||this.status>=500}getisPathMismatch(){returnthis.status===404||this.status===405}},I=class{constructor(r){this.activeBaseUrl="";this.runtimePathStyle=null;this.host=r}getActiveBaseUrl(){returnthis.activeBaseUrl}setActiveBaseUrl(r){lete=this.getCandidateBaseUrls(!1);r&&e.includes(r)&&(this.activeBaseUrl=r)}clearActiveBaseUrl(){this.activeBaseUrl=""}asyncprobeConnection(){letr=this.getCandidateBaseUrls(!1),e=newDate().toISOString(),t=[],i=null,n=null;for(letsofr){leto=Date.now();try{letl=awaitthis.listDatasetsFromBaseUrl(s),c=Date.now()-o;returnthis.activeBaseUrl=s,t.push({baseUrl:s,ok:!0,latencyMs:c,datasetCount:l.length}),{status:"connected",checkedAt:e,activeBaseUrl:s,lastSuccessfulBaseUrl:s,datasetCount:l.length,latency
RunSyncnowwhenneeded,orkeepautosyncenabled.`,helpApiUrlTitle:"How to fill connection settings",helpApiUrlBody:`DifyAPIKey:required.ItauthorizesaccesstoyourDifyknowledgebase.CopyitfromtheDifyknowledgebaseAPIsettings.Example:dataset-vtpB1fgqv************
DifyserviceURL:required.ThisisthemainaddressthepluginusestoconnecttoDify.ItworksforDifyonacloudserver,NAS,localDocker,oranotherreachablehost.Examples:http://dify-host.example.test:5000 or https://dify.example.com
IfyourDifyknowledgebaserunsonNASandyouwantaccessfromhome,work,oroutsidenetworks,installandconfigureTailscaleonboththeNASandyourlaptop.Thenenter:http://tailnet-device.example.test:Dify mapped port. Example: http://tailnet-device.example.test:5000`,helpApiKeyTitle:"API key requirements",helpApiKeyBody:"Use a Dify knowledge base API key with permission to access knowledge bases, list knowledge bases, create documents, update documents, and list documents. If the connection test reports insufficient permissions, check that the key belongs to the correct Dify instance, workspace, and knowledge base.",helpMappingTitle:"Path mappings",helpMappingBody:"Path mappings decide which Obsidian notes sync to which Dify knowledge bases. A folder syncs Markdown files in that folder and its subfolders; a note syncs only that note. Each mapping can be enabled or paused independently.",helpMappingList:`Sync one Obsidian folder or note to one knowledge base.
Concurrentuploads:1to2forNAS/Docker/smallerself-hosteddeployments.`,helpSyncRulesTitle:"Sync rules",helpSyncRulesBody:"The plugin only syncs .md files. It does not upload images, PDFs, attachments, or other non-Markdown files. Deleting a local note does not automatically delete the remote Dify document. Deleting a path mapping only removes local configuration and does not delete Obsidian files or remote Dify documents.",helpSyncRulesList:`Findtargetknowledgebasesfrompathmappings.
Difyreturnedaservererror:checktheDifycontainer,servicelogs,orreverseproxyupstream.`,helpDatasetsTitle:"Knowledge bases do not appear",helpDatasetsList:`TheAPIkeylacksknowledgebasepermissions.
TrySyncnowtoseparateevent-triggerissuesfromconnectionormappingissues.`,helpSlowSyncTitle:"Sync is slow",helpSlowSyncList:`Setconcurrentuploadsto1or2.
Avoidsyncingverylargefoldersallatonce.
Splitlargeknowledgebasesbyfolderandsyncinbatches.
Iftheconnectionisalsounstable,runTestconnectionandfollowconnectiontroubleshootingfirst.`,helpDuplicateDocsTitle:"Duplicate documents appear",helpDuplicateDocsBody:"Possible causes include missing legacy sync records, manually changed Dify document names, reset or lost local sync records, or remote documents that were manually deleted and then synced again.",helpDuplicateDocsList:`ConfirmduplicatedocumentsintheDifyconsole.
RunSyncnowagainsothepluginrebuildsrecords.`,helpDebugTitle:"Debug logs",helpDebugBody:"Temporarily enable debug logs when the error stays generic, browser access works but the plugin still fails, NAS / Docker / reverse proxy routing is complex, or you need to report an issue. Do not share API keys, private addresses, note content, or other sensitive information in logs.",helpPrivacyTitle:"Privacy and safety",helpPrivacyBody:"The plugin only reads Markdown files in the current Obsidian vault that match enabled path mappings. It only sends required Markdown content to your configured Dify service URL. It does not send note content to the plugin author or any third-party service other than your configured Dify service. The Dify API key is stored in Obsidian plugin local data; do not commit a {configDir} directory containing plugin settings to a public repository.",navAria:"Obsidian settings navigation",navAbout:"About",navEditor:"Editor",navFiles:"Files and links",navAppearance:"Appearance",navHotkeys:"Hotkeys",navPlugins:"Third-party plugins",clearConnectionConfig:"Clear config",selectPlaceholder:"Please select",showApiKey:"Show API key",hideApiKey:"Hide API key",healthConnection:"Connection",healthActiveUrl:"Active URL",healthRecentSync:"Recent sync",connectionUnknown:"Not tested",connectionMissing:"Needs setup",connectionConnected:"Connected",connectionFailedState:"Failed",recentSyncNone:"No sync yet",quickStepKey:"Enter key",quickStepKeyDesc:"Dify knowledge API key",quickStepTest:"Test connection",quickStepTestDesc:"Find an endpoint and load bases",quickStepMapping:"Add mapping",quickStepMappingDesc:"Choose folder and bases",sectionBasicConnection:"Basic connection",settingsReviewConnectionTitle:"Connection",settingsReviewMappingTitle:"Directory mapping",settingsReviewSyncTitle:"Sync settings",pendingMappingsTitle:"New mappings",bulkSet:"Bulk set",enableAll:"Enable all",pauseAll:"Pause all",chooseFolderFirst:"Select a folder or note first",pendingEmptyDesc:"Select an Obsidian folder or note on the left, then choose Dify knowledge bases on the right and click Add.",pendingAdded:"Mapping added to the list below.",selectFolderPlaceholder:"Select a folder or note",datasetsDropdownEmpty:"Load Dify knowledge bases first",folderSearch:"Search folders or notes",addPendingMapping:"Add",saveMapping:"Save mapping",syncAfterChange:"After changes",fullScanCheck:"Full check",startupSyncShort:"Startup sync",concurrentUpload:"Concurrent uploads",debounceOption8:"8 seconds",debounceOption15:"15 seconds",debounceOption30:"30 seconds",fullScanOption30:"Every 30 minutes",fullScanOption60:"Every 60 minutes",fullScanOptionOff:"Off",concurrencyOption2:"2 files",concurrencyOption4:"4 files",optionOn:"On",optionOff:"Off",settingsReviewLanUrlName:"NAS LAN address",settingsReviewLanUrlPlaceholder:"Enter NAS LAN address",settingsReviewPublicUrlName:"NAS public address",settingsReviewPublicUrlPlaceholder:"Enter NAS public address",basicConnectionDesc:"First-time setup keeps only the essentials; advanced endpoint options are collapsed.",apiUrlName:"Dify service URL",apiUrlDesc:"Use the Dify service URL reachable from this Obsidian device. You may omit http:// or paste a URL ending in /v1 or /v1/datasets.",connectionNoteIdle:"Enter an API key and Dify service URL, then test the connection.",connectionNoteMissing:"Enter an API key and Dify service URL first.",connectionNoteSuccess:"Connected: {count} knowledge bases via {url}.",connectionNoteFailed:"Connection failed: {message}",advancedConnectionSummary:"Advanced connection: LAN/public fallback URLs, API path compatibility, timeout, retries",expand:"Expand",collapse:"Collapse",advancedSync:"Tune advanced options",syncCadenceName:"Sync cadence",syncCadenceDesc:"Sync {debounce}s after changes; run a full check every {interval} minutes.",syncCadenceEventOnly:"Sync {debounce}s after changes; periodic full checks are off.",syncCadenceIntervalOnly:"File change sync is off; run a full check every {interval} minutes.",syncCadenceOff:"Auto sync is off. Manual sync still works.",sectionDiagnostics:"Sy