yanki
Version:
A CLI tool and TypeScript library to turn Markdown into Anki flashcards.
1 lines • 2.92 MB
JavaScript
import"node:path";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const u={defaultMerge:Symbol(`deepmerge-ts: default merge`),skip:Symbol(`deepmerge-ts: skip`)};u.defaultMerge;function d(e,t){return t}function f(e,t){return e.filter(e=>e!==void 0)}var p;(function(e){e[e.NOT=0]=`NOT`,e[e.RECORD=1]=`RECORD`,e[e.ARRAY=2]=`ARRAY`,e[e.SET=3]=`SET`,e[e.MAP=4]=`MAP`,e[e.OTHER=5]=`OTHER`})(p||={});function m(e){return typeof e!=`object`||!e?0:Array.isArray(e)?2:y(e)?1:e instanceof Set?3:e instanceof Map?4:5}function h(e){let t=new Set;for(let n of e)for(let e of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(e);return t}function g(e,t){return typeof e==`object`&&Object.prototype.propertyIsEnumerable.call(e,t)}function _(e){let t=0,n=e[0]?.[Symbol.iterator]();return{[Symbol.iterator](){return{next(){do{if(n===void 0)return{done:!0,value:void 0};let r=n.next();if(r.done===!0){t+=1,n=e[t]?.[Symbol.iterator]();continue}return{done:!1,value:r.value}}while(!0)}}}}}const v=[`[object Object]`,`[object Module]`];function y(e){if(!v.includes(Object.prototype.toString.call(e)))return!1;let{constructor:t}=e;if(t===void 0)return!0;let n=t.prototype;return!(typeof n!=`object`||!n||!v.includes(Object.prototype.toString.call(n))||!n.hasOwnProperty(`isPrototypeOf`))}function b(e,t,n){let r={};for(let i of h(e)){let a=[];for(let t of e)g(t,i)&&a.push(t[i]);if(a.length===0)continue;let o=re(a,t,t.metaDataUpdater(n,{key:i,parents:e}));o!==u.skip&&(i===`__proto__`?Object.defineProperty(r,i,{value:o,configurable:!0,enumerable:!0,writable:!0}):r[i]=o)}return r}function x(e){return e.flat()}function S(e){return new Set(_(e))}function ee(e){return new Map(_(e))}function te(e){return e.at(-1)}const C={mergeRecords:b,mergeArrays:x,mergeSets:S,mergeMaps:ee,mergeOthers:te};function w(...e){return ne({})(...e)}function ne(e,t){let n=T(e,r);function r(...e){return re(e,n,t)}return r}function T(e,t){return{defaultMergeFunctions:C,mergeFunctions:{...C,...Object.fromEntries(Object.entries(e).filter(([e,t])=>Object.hasOwn(C,e)).map(([e,t])=>t===!1?[e,C.mergeOthers]:[e,t]))},metaDataUpdater:e.metaDataUpdater??d,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,filterValues:e.filterValues===!1?void 0:e.filterValues??f,actions:u}}function re(e,t,n){let r=t.filterValues?.(e,n)??e;if(r.length===0)return;if(r.length===1)return ce(r,t,n);let i=m(r[0]);if(i!==0&&i!==5){for(let e=1;e<r.length;e++)if(m(r[e])!==i)return ce(r,t,n)}switch(i){case 1:return ie(r,t,n);case 2:return ae(r,t,n);case 3:return oe(r,t,n);case 4:return se(r,t,n);default:return ce(r,t,n)}}function ie(e,t,n){let r=t.mergeFunctions.mergeRecords(e,t,n);return r===u.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):r}function ae(e,t,n){let r=t.mergeFunctions.mergeArrays(e,t,n);return r===u.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):r}function oe(e,t,n){let r=t.mergeFunctions.mergeSets(e,t,n);return r===u.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):r}function se(e,t,n){let r=t.mergeFunctions.mergeMaps(e,t,n);return r===u.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):r}function ce(e,t,n){let r=t.mergeFunctions.mergeOthers(e,t,n);return r===u.defaultMerge||t.useImplicitDefaultMerging&&r===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):r}const le=new Map(Object.entries({abscissa:`abscissae`,addendum:`addenda`,adulthood:`adulthood`,advice:`advice`,afreet:`afreets`,afrit:`afrits`,agendum:`agenda`,aid:`aid`,aircraft:`aircraft`,albino:`albinos`,alcohol:`alcohol`,alga:`algae`,alto:`altos`,alumna:`alumnae`,alumnus:`alumni`,alveolus:`alveoli`,amoeba:`amoebas`,ammo:`ammo`,analysis:`analyses`,analytics:`analytics`,anathema:`anathemas`,anime:`anime`,antenna:`antennas`,antithesis:`antitheses`,aphelion:`aphelia`,apparatus:`apparatuses`,appendix:`appendixes`,aquarium:`aquariums`,archipelago:`archipelagos`,armadillo:`armadillos`,asyndeton:`asyndetons`,athletics:`athletics`,audio:`audio`,aurora:`auroras`,automaton:`automatons`,axis:`axes`,bacillus:`bacilli`,bacterium:`bacteria`,baculum:`bacula`,barracks:`barracks`,basis:`bases`,basso:`bassos`,beau:`beaus`,beef:`beefs`,blood:`blood`,bema:`bemas`,biceps:`biceps`,bison:`bison`,bream:`bream`,breeches:`breeches`,britches:`britches`,brother:`brothers`,buffalo:`buffalo`,bureau:`bureaus`,businessman:`businessmen`,butter:`butter`,cactus:`cactuses`,calf:`calves`,cash:`cash`,candelabrum:`candelabra`,canto:`cantos`,cantus:`cantus`,carcinoma:`carcinomas`,carp:`carp`,census:`censuses`,chapeau:`chapeaus`,charisma:`charismas`,chairman:`chairmen`,chassis:`chassis`,cherub:`cherubs`,chess:`chess`,child:`children`,château:`châteaus`,clippers:`clippers`,clitoris:`clitorises`,clothes:`clothes`,clothing:`clothing`,cloaca:`cloacae`,cod:`cod`,codex:`codices`,commerce:`commerce`,coitus:`coitus`,commando:`commandos`,compendium:`compendiums`,concerto:`concertos`,consortium:`consortia`,contralto:`contraltos`,contretemps:`contretemps`,cooperation:`cooperation`,corps:`corps`,corpus:`corpora`,cortex:`cortices`,cranium:`crania`,crescendo:`crescendos`,crisis:`crises`,criterion:`criteria`,curriculum:`curricula`,cyclops:`cyclopses`,cystoma:`cystomata`,data:`data`,datum:`data`,debris:`debris`,deer:`deer`,desideratum:`desiderata`,diabetes:`diabetes`,diagnosis:`diagnoses`,dictum:`dicta`,die:`dice`,digestion:`digestion`,dingo:`dingoes`,diploma:`diplomas`,ditto:`dittos`,djinni:`djinn`,dogma:`dogmata`,drama:`dramas`,dwarf:`dwarfs`,dynamo:`dynamos`,economics:`economics`,echo:`echoes`,edema:`edemas`,efreet:`efreets`,eland:`eland`,elf:`elves`,elk:`elk`,ellipsis:`ellipses`,embargo:`embargoes`,embryo:`embryos`,emphasis:`emphases`,emporium:`emporia`,encomium:`encomia`,enigma:`enigmas`,equipment:`equipment`,ephemeris:`ephemerides`,erratum:`errata`,excretion:`excretion`,expertise:`expertise`,extremum:`extrema`,"faux pas":`faux pas`,fez:`fezzes`,fiasco:`fiascos`,fibula:`fibulae`,firmware:`firmware`,fish:`fish`,flounder:`flounder`,focus:`focuses`,foot:`feet`,fun:`fun`,foramen:`foramina`,formula:`formulas`,forum:`forums`,fungus:`fungi`,gallows:`gallows`,garbage:`garbage`,ganglion:`ganglia`,generalissimo:`generalissimos`,genie:`genies`,gentleman:`gentlemen`,genus:`genera`,ghetto:`ghettos`,glomerulus:`glomeruli`,goose:`geese`,goy:`goyim`,graffiti:`graffiti`,graffito:`graffiti`,grouse:`grouse`,guano:`guano`,gumma:`gummata`,gymnasium:`gymnasiums`,half:`halves`,hamulus:`hamuli`,hardware:`hardware`,health:`health`,headquarters:`headquarters`,hero:`heroes`,herpes:`herpes`,highjinks:`highjinks`,hijinks:`hijinks`,hiatus:`hiatuses`,hippopotamus:`hippopotamuses`,homework:`homework`,honorarium:`honoraria`,hoof:`hooves`,housework:`housework`,hovercraft:`hovercraft`,humerus:`humeri`,hyperbaton:`hyperbata`,hyperbola:`hyperbolae`,hypothesis:`hypotheses`,ilium:`ilia`,impetus:`impetuses`,incubus:`incubi`,index:`indexes`,information:`information`,inferno:`infernos`,innings:`innings`,interregnum:`interregna`,interstitium:`interstitia`,jackanapes:`jackanapes`,jeans:`jeans`,jumbo:`jumbos`,kakapo:`kakapo`,knife:`knives`,kudos:`kudos`,labour:`labour`,lacuna:`lacunas`,larva:`larvae`,leaf:`leaves`,lemma:`lemmas`,libretto:`librettos`,life:`lives`,lingo:`lingos`,literature:`literature`,loaf:`loaves`,loculus:`loculi`,locus:`loci`,looey:`looies`,louse:`lice`,lumbago:`lumbagos`,lumen:`lumina`,lustrum:`lustra`,lymphoma:`lymphomata`,machinery:`machinery`,mackerel:`mackerel`,magma:`magmas`,mail:`mail`,magneto:`magnetos`,man:`men`,manga:`manga`,manifesto:`manifestos`,matrix:`matrices`,maximum:`maxima`,means:`means`,measles:`measles`,medico:`medicos`,medium:`media`,melisma:`melismas`,memorandum:`memoranda`,meniscus:`menisci`,mews:`mews`,miasma:`miasmas`,millennium:`millennia`,minimum:`minima`,minutia:`minutiae`,momentum:`momenta`,mongoose:`mongooses`,moose:`moose`,mud:`mud`,mouse:`mice`,mumps:`mumps`,music:`music`,murex:`murices`,mythos:`mythoi`,nebula:`nebulas`,nemesis:`nemeses`,neurosis:`neuroses`,news:`news`,nexus:`nexuses`,nimbus:`nimbuses`,noumenon:`noumena`,nova:`novas`,nucleolus:`nucleoli`,nucleus:`nuclei`,oasis:`oases`,occiput:`occipita`,octavo:`octavos`,octopus:`octopuses`,oedema:`oedemas`,offspring:`offspring`,omphalos:`omphaloi`,optimum:`optima`,opus:`opuses`,organon:`organons`,ovum:`ova`,ox:`oxen`,parabola:`parabolas`,paralysis:`paralyses`,parenthesis:`parentheses`,passerby:`passersby`,penny:`pennies`,personnel:`personnel`,perihelion:`perihelia`,person:`people`,phalanx:`phalanges`,phenomenon:`phenomena`,photo:`photos`,physics:`physics`,phylum:`phyla`,pike:`pike`,pincers:`pincers`,plankton:`plankton`,plateau:`plateaus`,platypus:`platypuses`,plexus:`plexuses`,pliers:`pliers`,police:`police`,policeman:`policemen`,politics:`politics`,pollution:`pollution`,polyhedron:`polyhedra`,pontifex:`pontifices`,potato:`potatoes`,premises:`premises`,pro:`pros`,proceedings:`proceedings`,prognosis:`prognoses`,prolegomenon:`prolegomena`,prospectus:`prospectuses`,quantum:`quanta`,quarto:`quartos`,quiz:`quizzes`,rabies:`rabies`,rain:`rain`,radius:`radii`,referendum:`referendums`,reindeer:`reindeer`,research:`research`,rhino:`rhinos`,rice:`rice`,roof:`roofs`,rostrum:`rostrums`,salmon:`salmon`,sarcoma:`sarcomas`,sarcophagus:`sarcophagi`,savings:`savings`,scarf:`scarves`,schema:`schemas`,scissors:`scissors`,scrotum:`scrota`,"sea bass":`sea bass`,sewage:`sewage`,self:`selves`,seminoma:`seminomas`,shambles:`shambles`,seraph:`seraphs`,series:`series`,shears:`shears`,sheep:`sheep`,shelf:`shelves`,shrimp:`shrimp`,silex:`silices`,simplex:`simplexes`,simulacrum:`simulacra`,software:`software`,sinus:`sinuses`,soliloquy:`soliloquies`,solo:`solos`,soma:`somas`,soprano:`sopranos`,spacecraft:`spacecraft`,spokesman:`spokesmen`,species:`species`,spectrum:`spectra`,speculum:`specula`,sphinx:`sphinxes`,squid:`squid`,stadium:`stadiums`,staff:`staffs`,stairs:`stairs`,stamen:`stamens`,status:`statuses`,stigma:`stigmas`,stimulus:`stimuli`,stoma:`stomas`,stratum:`strata`,stylus:`styluses`,succubus:`succubi`,swine:`swine`,syconium:`syconia`,syllabus:`syllabuses`,symposium:`symposiums`,synopsis:`synopses`,synthesis:`syntheses`,tennis:`tennis`,tableau:`tableaus`,tempo:`tempos`,thanks:`thanks`,testis:`testes`,that:`those`,thesis:`theses`,thief:`thieves`,this:`these`,thrombus:`thrombi`,tibia:`tibias`,tomato:`tomatoes`,tooth:`teeth`,torpedo:`torpedoes`,tornado:`tornadoes`,torus:`tori`,traffic:`traffic`,transportation:`transportation`,trapezium:`trapezia`,trauma:`traumas`,triceps:`triceps`,trilby:`trilbies`,trout:`trout`,tuna:`tuna`,ultimatum:`ultimatums`,umbilicus:`umbilici`,upstairs:`upstairs`,uterus:`uteruses`,vacuum:`vacuums`,velum:`vela`,vertebra:`vertebrae`,vertex:`vertices`,veto:`vetoes`,viscus:`viscera`,wealth:`wealth`,welfare:`welfare`,vita:`vitae`,volcano:`volcanoes`,vortex:`vortices`,watercraft:`watercraft`,wharf:`wharves`,whiting:`whiting`,wife:`wives`,wildebeest:`wildebeest`,wildlife:`wildlife`,wolf:`wolves`,woman:`women`}));function ue(e,t,n){if(typeof t==`number`&&(n=t),le.has(e.toLowerCase())){t=le.get(e.toLowerCase());let n=e.charAt(0);n===n.toUpperCase()&&(t=n+t.slice(1)),e===e.toUpperCase()&&(t=t.toUpperCase())}else typeof t!=`string`&&(t=(e.replace(/(?:s|x|z|ch|sh)$/i,`$&e`).replace(/([^aeiou])y$/i,`$1ie`)+`s`).replace(/i?e?s$/i,t=>e.slice(-1)===e.slice(-1).toLowerCase()?t.toLowerCase():t.toUpperCase()));return Math.abs(n)===1?e:t}const de=e=>Number.isFinite(e)?e:0;function fe(e){return{days:Math.trunc(e/864e5),hours:Math.trunc(e/36e5%24),minutes:Math.trunc(e/6e4%60),seconds:Math.trunc(e/1e3%60),milliseconds:Math.trunc(e%1e3),microseconds:Math.trunc(de(e*1e3)%1e3),nanoseconds:Math.trunc(de(e*1e6)%1e3)}}function pe(e){return{days:e/86400000n,hours:e/3600000n%24n,minutes:e/60000n%60n,seconds:e/1000n%60n,milliseconds:e%1000n,microseconds:0n,nanoseconds:0n}}function me(e){switch(typeof e){case`number`:if(Number.isFinite(e))return fe(e);break;case`bigint`:return pe(e)}throw TypeError(`Expected a finite number or bigint`)}const he=e=>e===0||e===0n,ge=(e,t)=>t===1||t===1n?e:`${e}s`,_e=24n*60n*60n*1000n;function ve(e,t){let n=typeof e==`bigint`;if(!n&&!Number.isFinite(e))throw TypeError(`Expected a finite number or bigint`);t={...t};let r=e<0?`-`:``;e=e<0?-e:e,t.colonNotation&&(t.compact=!1,t.formatSubMilliseconds=!1,t.separateMilliseconds=!1,t.verbose=!1),t.compact&&(t.unitCount=1,t.secondsDecimalDigits=0,t.millisecondsDecimalDigits=0);let i=[],a=(e,t)=>{let n=Math.floor(e*10**t+1e-7);return(Math.round(n)/10**t).toFixed(t)},o=(e,n,r,a)=>{if(!((i.length===0||!t.colonNotation)&&he(e)&&!(t.colonNotation&&r===`m`))){if(a??=String(e),t.colonNotation){let e=a.includes(`.`)?a.split(`.`)[0].length:a.length,t=i.length>0?2:1;a=`0`.repeat(Math.max(0,t-e))+a}else a+=t.verbose?` `+ge(n,e):r;i.push(a)}},s=me(e),c=BigInt(s.days);if(t.hideYearAndDays?o(BigInt(c)*24n+BigInt(s.hours),`hour`,`h`):(t.hideYear?o(c,`day`,`d`):(o(c/365n,`year`,`y`),o(c%365n,`day`,`d`)),o(Number(s.hours),`hour`,`h`)),o(Number(s.minutes),`minute`,`m`),!t.hideSeconds)if(t.separateMilliseconds||t.formatSubMilliseconds||!t.colonNotation&&e<1e3&&!t.subSecondsAsDecimals){let e=Number(s.seconds),n=Number(s.milliseconds),r=Number(s.microseconds),i=Number(s.nanoseconds);if(o(e,`second`,`s`),t.formatSubMilliseconds)o(n,`millisecond`,`ms`),o(r,`microsecond`,`µs`),o(i,`nanosecond`,`ns`);else{let e=n+r/1e3+i/1e6,a=typeof t.millisecondsDecimalDigits==`number`?t.millisecondsDecimalDigits:0,s=a?e.toFixed(a):e>=1?Math.round(e):Math.ceil(e);o(Number.parseFloat(s),`millisecond`,`ms`,s)}}else{let r=a((n?Number(e%_e):e)/1e3%60,typeof t.secondsDecimalDigits==`number`?t.secondsDecimalDigits:1),i=t.keepDecimalsOnWholeSeconds?r:r.replace(/\.0+$/,``);o(Number.parseFloat(i),`second`,`s`,i)}if(i.length===0)return r+`0`+(t.verbose?` milliseconds`:`ms`);let l=t.colonNotation?`:`:` `;return typeof t.unitCount==`number`&&(i=i.slice(0,Math.max(t.unitCount,1))),r+i.join(l)}const ye=typeof window>`u`?typeof process>`u`?`other`:`node`:`browser`,be=ye===`browser`?/windows/i.test(navigator.userAgent)?`windows`:/mac/i.test(navigator.userAgent)?`mac`:`other`:ye===`node`?process.platform===`win32`?`windows`:process.platform===`darwin`?`mac`:`other`:`other`;let xe=0,Se=0;async function Ce(){if(be===`mac`&&ye===`node`){let{openApp:e}=await import(`./open-DsJJlGt1.js`);if(Se>=100){console.warn(`Too many Anki App launch attempts this session, ignoring`);return}(xe===0||Date.now()-xe>5e3)&&(console.warn(`Attempting to launch Anki app`),xe=Date.now(),Se++,await e(`/Applications/Anki.app`,{background:!0,newInstance:!1,wait:!1}))}else console.warn(`Automatic Anki App launch is only supported on macOS in Node.js environment`)}const we={autoLaunch:!1,fetchAdapter:fetch.bind(globalThis),host:`http://127.0.0.1`,key:void 0,port:8765,version:6};var Te=class{card={answerCards:this.build(`answerCards`),areDue:this.build(`areDue`),areSuspended:this.build(`areSuspended`),cardsInfo:this.build(`cardsInfo`),cardsModTime:this.build(`cardsModTime`),cardsToNotes:this.build(`cardsToNotes`),findCards:this.build(`findCards`),forgetCards:this.build(`forgetCards`),getEaseFactors:this.build(`getEaseFactors`),getIntervals:this.build(`getIntervals`),relearnCards:this.build(`relearnCards`),setDueDate:this.build(`setDueDate`),setEaseFactors:this.build(`setEaseFactors`),setSpecificValueOfCard:this.build(`setSpecificValueOfCard`),suspend:this.build(`suspend`),suspended:this.build(`suspended`),unsuspend:this.build(`unsuspend`)};deck={changeDeck:this.build(`changeDeck`),cloneDeckConfigId:this.build(`cloneDeckConfigId`),createDeck:this.build(`createDeck`),deckNames:this.build(`deckNames`),deckNamesAndIds:this.build(`deckNamesAndIds`),deleteDecks:this.build(`deleteDecks`),getDeckConfig:this.build(`getDeckConfig`),getDecks:this.build(`getDecks`),getDeckStats:this.build(`getDeckStats`),removeDeckConfigId:this.build(`removeDeckConfigId`),saveDeckConfig:this.build(`saveDeckConfig`),setDeckConfigId:this.build(`setDeckConfigId`)};graphical={guiAddCards:this.build(`guiAddCards`),guiAnswerCard:this.build(`guiAnswerCard`),guiBrowse:this.build(`guiBrowse`),guiCheckDatabase:this.build(`guiCheckDatabase`),guiCurrentCard:this.build(`guiCurrentCard`),guiDeckBrowser:this.build(`guiDeckBrowser`),guiDeckOverview:this.build(`guiDeckOverview`),guiDeckReview:this.build(`guiDeckReview`),guiEditNote:this.build(`guiEditNote`),guiExitAnki:this.build(`guiExitAnki`),guiImportFile:this.build(`guiImportFile`),guiPlayAudio:this.build(`guiPlayAudio`),guiSelectCard:this.build(`guiSelectCard`),guiSelectedNotes:this.build(`guiSelectedNotes`),guiSelectNote:this.build(`guiSelectNote`),guiShowAnswer:this.build(`guiShowAnswer`),guiShowQuestion:this.build(`guiShowQuestion`),guiStartCardTimer:this.build(`guiStartCardTimer`),guiUndo:this.build(`guiUndo`)};media={deleteMediaFile:this.build(`deleteMediaFile`),getMediaDirPath:this.build(`getMediaDirPath`),getMediaFilesNames:this.build(`getMediaFilesNames`),retrieveMediaFile:this.build(`retrieveMediaFile`),storeMediaFile:this.build(`storeMediaFile`)};miscellaneous={apiReflect:this.build(`apiReflect`),exportPackage:this.build(`exportPackage`),getActiveProfile:this.build(`getActiveProfile`),getProfiles:this.build(`getProfiles`),importPackage:this.build(`importPackage`),loadProfile:this.build(`loadProfile`),multi:this.build(`multi`),reloadCollection:this.build(`reloadCollection`),requestPermission:this.build(`requestPermission`),sync:this.build(`sync`),version:this.build(`version`)};model={createModel:this.build(`createModel`),findAndReplaceInModels:this.build(`findAndReplaceInModels`),findModelsById:this.build(`findModelsById`),findModelsByName:this.build(`findModelsByName`),modelFieldAdd:this.build(`modelFieldAdd`),modelFieldDescriptions:this.build(`modelFieldDescriptions`),modelFieldFonts:this.build(`modelFieldFonts`),modelFieldNames:this.build(`modelFieldNames`),modelFieldRemove:this.build(`modelFieldRemove`),modelFieldRename:this.build(`modelFieldRename`),modelFieldReposition:this.build(`modelFieldReposition`),modelFieldSetDescription:this.build(`modelFieldSetDescription`),modelFieldSetFont:this.build(`modelFieldSetFont`),modelFieldSetFontSize:this.build(`modelFieldSetFontSize`),modelFieldsOnTemplates:this.build(`modelFieldsOnTemplates`),modelNames:this.build(`modelNames`),modelNamesAndIds:this.build(`modelNamesAndIds`),modelStyling:this.build(`modelStyling`),modelTemplateAdd:this.build(`modelTemplateAdd`),modelTemplateRemove:this.build(`modelTemplateRemove`),modelTemplateRename:this.build(`modelTemplateRename`),modelTemplateReposition:this.build(`modelTemplateReposition`),modelTemplates:this.build(`modelTemplates`),updateModelStyling:this.build(`updateModelStyling`),updateModelTemplates:this.build(`updateModelTemplates`)};note={addNote:this.build(`addNote`),addNotes:this.build(`addNotes`),addTags:this.build(`addTags`),canAddNotes:this.build(`canAddNotes`),canAddNotesWithErrorDetail:this.build(`canAddNotesWithErrorDetail`),clearUnusedTags:this.build(`clearUnusedTags`),deleteNotes:this.build(`deleteNotes`),findNotes:this.build(`findNotes`),getNoteTags:this.build(`getNoteTags`),getTags:this.build(`getTags`),notesInfo:this.build(`notesInfo`),notesModTime:this.build(`notesInfo`),removeEmptyNotes:this.build(`removeEmptyNotes`),removeTags:this.build(`removeTags`),replaceTags:this.build(`replaceTags`),replaceTagsInAllNotes:this.build(`replaceTagsInAllNotes`),updateNote:this.build(`updateNote`),updateNoteFields:this.build(`updateNoteFields`),updateNoteModel:this.build(`updateNoteModel`),updateNoteTags:this.build(`updateNoteTags`)};statistic={cardReviews:this.build(`cardReviews`),getCollectionStatsHTML:this.build(`getCollectionStatsHTML`),getLatestReviewID:this.build(`getLatestReviewID`),getNumCardsReviewedByDay:this.build(`getNumCardsReviewedByDay`),getNumCardsReviewedToday:this.build(`getNumCardsReviewedToday`),getReviewsOfCards:this.build(`getReviewsOfCards`),insertReviews:this.build(`insertReviews`)};autoLaunch;fetchAdapter;host;key;port;version;constructor(e){if(this.host=e?.host??we.host,this.port=e?.port??we.port,this.version=e?.version??we.version,this.key=e?.key??we.key,this.autoLaunch=e?.autoLaunch??we.autoLaunch,we.fetchAdapter===void 0)throw Error(`A fetch implementation is required`);if(this.fetchAdapter=e?.fetchAdapter??we.fetchAdapter,(be!==`mac`||ye!==`node`)&&this.autoLaunch!==!1&&(console.warn(`The autoLaunch option is only supported in a Node environment on macOS`),this.autoLaunch=!1),this.version!==6)throw Error(`YankiConnect currently only supports AnkiConnect API version 6`);this.autoLaunch===`immediately`&&Ce()}async invoke(e,t){let n,r;try{if(n=await this.fetchAdapter(`${this.host}:${this.port}`,{body:JSON.stringify({action:e,...this.key===void 0?{}:{key:this.key},params:t,version:this.version}),headers:{"Access-Control-Allow-Origin":`*`,"Content-Type":`application/json`},method:`POST`,mode:`cors`}),n===void 0)throw Error(`AnkiConnect response is undefined`);if(n.status!==200)throw Error(`AnkiConnect response status is ${n.status}`);if(r=await n.json(),this.autoLaunch!==!1&&r.error===`collection is not available`)throw Error(r.error)}catch(n){if(this.autoLaunch!==!1)return console.warn(`Can't connect to Anki app, retrying with auto-launch...`),await Ce(),await new Promise(e=>{setTimeout(e,500)}),t===void 0?this.invoke(e):this.invoke(e,t);throw n}if(!(`error`in r))throw Error(`response is missing required error field`);if(!(`result`in r))throw Error(`response is missing required result field`);return r}build(e){return async t=>{let n=await this.invoke(e,t);if(n.error!==null)throw Error(n.error);return n.result}}},Ee=[Object.freeze(JSON.parse(`{"displayName":"Shell","name":"shellscript","patterns":[{"include":"#initial_context"}],"repository":{"alias_statement":{"begin":"[\\\\t ]*+(alias)[\\\\t ]*+((?:((?<!\\\\w)-\\\\w+)\\\\b[\\\\t ]*+)*)[\\\\t ]*+((?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w))(?:(\\\\[)((?:(?:\\\\$?(?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w)|@)|\\\\*)|(-?\\\\d+))(]))?(?:(?:(=)|(\\\\+=))|(-=))","beginCaptures":{"1":{"name":"storage.type.alias.shell"},"2":{"patterns":[{"match":"(?<!\\\\w)-\\\\w+\\\\b","name":"string.unquoted.argument.shell constant.other.option.shell"}]},"3":{"name":"string.unquoted.argument.shell constant.other.option.shell"},"4":{"name":"variable.other.assignment.shell"},"5":{"name":"punctuation.definition.array.access.shell"},"6":{"name":"variable.other.assignment.shell"},"7":{"name":"constant.numeric.shell constant.numeric.integer.shell"},"8":{"name":"punctuation.definition.array.access.shell"},"9":{"name":"keyword.operator.assignment.shell"},"10":{"name":"keyword.operator.assignment.compound.shell"},"11":{"name":"keyword.operator.assignment.compound.shell"}},"end":"(?=[\\\\t ]|$)|(?:(?:(?:(;)|(&&))|(\\\\|\\\\|))|(&))","endCaptures":{"1":{"name":"punctuation.terminator.statement.semicolon.shell"},"2":{"name":"punctuation.separator.statement.and.shell"},"3":{"name":"punctuation.separator.statement.or.shell"},"4":{"name":"punctuation.separator.statement.background.shell"}},"name":"meta.expression.assignment.alias.shell","patterns":[{"include":"#normal_context"}]},"argument":{"begin":"[\\\\t ]++(?![\\\\n#\\\\&(\\\\[|]|$|;)","beginCaptures":{},"end":"(?=[\\\\t \\\\&;|]|$|[\\\\n)\`])","endCaptures":{},"name":"meta.argument.shell","patterns":[{"include":"#argument_context"},{"include":"#line_continuation"}]},"argument_context":{"patterns":[{"captures":{"1":{"name":"string.unquoted.argument.shell","patterns":[{"match":"\\\\*","name":"variable.language.special.wildcard.shell"},{"include":"#variable"},{"include":"#numeric_literal"},{"captures":{"1":{"name":"constant.language.$1.shell"}},"match":"(?<!\\\\w)\\\\b(true|false)\\\\b(?!\\\\w)"}]}},"match":"[\\\\t ]*+([^\\\\t\\\\n \\"$\\\\&-);<>\\\\\\\\\`|]+(?!>))"},{"include":"#normal_context"}]},"arithmetic_double":{"patterns":[{"begin":"\\\\(\\\\(","beginCaptures":{"0":{"name":"punctuation.section.arithmetic.double.shell"}},"end":"\\\\)\\\\s*\\\\)","endCaptures":{"0":{"name":"punctuation.section.arithmetic.double.shell"}},"name":"meta.arithmetic.shell","patterns":[{"include":"#math"},{"include":"#string"}]}]},"arithmetic_no_dollar":{"patterns":[{"begin":"\\\\(","beginCaptures":{"0":{"name":"punctuation.section.arithmetic.single.shell"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.section.arithmetic.single.shell"}},"name":"meta.arithmetic.shell","patterns":[{"include":"#math"},{"include":"#string"}]}]},"array_access_inline":{"captures":{"1":{"name":"punctuation.section.array.shell"},"2":{"patterns":[{"include":"#special_expansion"},{"include":"#string"},{"include":"#variable"}]},"3":{"name":"punctuation.section.array.shell"}},"match":"(\\\\[)([^]\\\\[]+)(])"},"array_value":{"begin":"[\\\\t ]*+((?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w))(?:(\\\\[)((?:(?:\\\\$?(?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w)|@)|\\\\*)|(-?\\\\d+))(]))?(?:(?:(=)|(\\\\+=))|(-=))[\\\\t ]*+(\\\\()","beginCaptures":{"1":{"name":"variable.other.assignment.shell"},"2":{"name":"punctuation.definition.array.access.shell"},"3":{"name":"variable.other.assignment.shell"},"4":{"name":"constant.numeric.shell constant.numeric.integer.shell"},"5":{"name":"punctuation.definition.array.access.shell"},"6":{"name":"keyword.operator.assignment.shell"},"7":{"name":"keyword.operator.assignment.compound.shell"},"8":{"name":"keyword.operator.assignment.compound.shell"},"9":{"name":"punctuation.definition.array.shell"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.array.shell"}},"patterns":[{"include":"#comment"},{"captures":{"1":{"name":"variable.other.assignment.array.shell entity.other.attribute-name.shell"},"2":{"name":"keyword.operator.assignment.shell punctuation.definition.assignment.shell"}},"match":"((?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w))(=)"},{"captures":{"1":{"name":"punctuation.definition.bracket.named-array.shell"},"2":{"name":"string.unquoted.shell entity.other.attribute-name.bracket.shell"},"3":{"name":"punctuation.definition.bracket.named-array.shell"},"4":{"name":"punctuation.definition.assignment.shell"}},"match":"(\\\\[)(.+?)(])(=)"},{"include":"#normal_context"},{"include":"#simple_unquoted"}]},"assignment_statement":{"patterns":[{"include":"#array_value"},{"include":"#modified_assignment_statement"},{"include":"#normal_assignment_statement"}]},"basic_command_name":{"captures":{"1":{"name":"storage.modifier.$1.shell"},"2":{"name":"entity.name.function.call.shell entity.name.command.shell","patterns":[{"match":"(?<!\\\\w)(?:continue|return|break)(?!\\\\w)","name":"keyword.control.$0.shell"},{"match":"(?<!\\\\w)(?:unfunction|continue|autoload|unsetopt|bindkey|builtin|getopts|command|declare|unalias|history|unlimit|typeset|suspend|source|printf|unhash|disown|ulimit|return|which|alias|break|false|print|shift|times|umask|unset|read|type|exec|eval|wait|echo|dirs|jobs|kill|hash|stat|exit|test|trap|true|let|set|pwd|cd|fg|bg|fc|[.:])(?!/)(?!\\\\w)(?!-)","name":"support.function.builtin.shell"},{"include":"#variable"}]}},"match":"(?![\\\\n!#\\\\&()<>\\\\[{|]|$|[\\\\t ;])(?!nocorrect |nocorrect\\\\t|nocorrect$|readonly |readonly\\\\t|readonly$|function |function\\\\t|function$|foreach |foreach\\\\t|foreach$|coproc |coproc\\\\t|coproc$|logout |logout\\\\t|logout$|export |export\\\\t|export$|select |select\\\\t|select$|repeat |repeat\\\\t|repeat$|pushd |pushd\\\\t|pushd$|until |until\\\\t|until$|while |while\\\\t|while$|local |local\\\\t|local$|case |case\\\\t|case$|done |done\\\\t|done$|elif |elif\\\\t|elif$|else |else\\\\t|else$|esac |esac\\\\t|esac$|popd |popd\\\\t|popd$|then |then\\\\t|then$|time |time\\\\t|time$|for |for\\\\t|for$|end |end\\\\t|end$|fi |fi\\\\t|fi$|do |do\\\\t|do$|in |in\\\\t|in$|if |if\\\\t|if$)(?:((?<=^|[\\\\t \\\\&;])(?:readonly|declare|typeset|export|local)(?=[\\\\t \\\\&;]|$))|((?![\\"']|\\\\\\\\\\\\n?$)[^\\\\t\\\\n\\\\r !\\"'<>]+?))(?:(?=[\\\\t ])|(?=[\\\\n\\\\&);\`{|}]|[\\\\t ]*#|])(?<!\\\\\\\\))","name":"meta.statement.command.name.basic.shell"},"block_comment":{"begin":"\\\\s*+(/\\\\*)","beginCaptures":{"1":{"name":"punctuation.definition.comment.begin.shell"}},"end":"\\\\*/","endCaptures":{"0":{"name":"punctuation.definition.comment.end.shell"}},"name":"comment.block.shell"},"boolean":{"match":"\\\\b(?:true|false)\\\\b","name":"constant.language.$0.shell"},"case_statement":{"begin":"\\\\b(case)\\\\b[\\\\t ]*+(.+?)[\\\\t ]*+\\\\b(in)\\\\b","beginCaptures":{"1":{"name":"keyword.control.case.shell"},"2":{"patterns":[{"include":"#initial_context"}]},"3":{"name":"keyword.control.in.shell"}},"end":"\\\\besac\\\\b","endCaptures":{"0":{"name":"keyword.control.esac.shell"}},"name":"meta.case.shell","patterns":[{"include":"#comment"},{"captures":{"1":{"name":"keyword.operator.pattern.case.default.shell"}},"match":"[\\\\t ]*+(\\\\* *\\\\))"},{"begin":"(?<!\\\\))(?![\\\\t ]*+(?:esac\\\\b|$))","beginCaptures":{},"end":"(?=\\\\besac\\\\b)|(\\\\))","endCaptures":{"1":{"name":"keyword.operator.pattern.case.shell"}},"name":"meta.case.entry.pattern.shell","patterns":[{"include":"#case_statement_context"}]},{"begin":"(?<=\\\\))","beginCaptures":{},"end":"(;;)|(?=\\\\besac\\\\b)","endCaptures":{"1":{"name":"punctuation.terminator.statement.case.shell"}},"name":"meta.case.entry.body.shell","patterns":[{"include":"#typical_statements"},{"include":"#initial_context"}]}]},"case_statement_context":{"patterns":[{"match":"\\\\*","name":"variable.language.special.quantifier.star.shell keyword.operator.quantifier.star.shell punctuation.definition.arbitrary-repetition.shell punctuation.definition.regex.arbitrary-repetition.shell"},{"match":"\\\\+","name":"variable.language.special.quantifier.plus.shell keyword.operator.quantifier.plus.shell punctuation.definition.arbitrary-repetition.shell punctuation.definition.regex.arbitrary-repetition.shell"},{"match":"\\\\?","name":"variable.language.special.quantifier.question.shell keyword.operator.quantifier.question.shell punctuation.definition.arbitrary-repetition.shell punctuation.definition.regex.arbitrary-repetition.shell"},{"match":"@","name":"variable.language.special.at.shell keyword.operator.at.shell punctuation.definition.regex.at.shell"},{"match":"\\\\|","name":"keyword.operator.orvariable.language.special.or.shell keyword.operator.alternation.ruby.shell punctuation.definition.regex.alternation.shell punctuation.separator.regex.alternation.shell"},{"match":"\\\\\\\\.","name":"constant.character.escape.shell"},{"match":"(?<=\\\\tin| in|[\\\\t ]|;;)\\\\(","name":"keyword.operator.pattern.case.shell"},{"begin":"(?<=\\\\S)(\\\\()","beginCaptures":{"1":{"name":"punctuation.definition.group.shell punctuation.definition.regex.group.shell"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.group.shell punctuation.definition.regex.group.shell"}},"name":"meta.parenthese.shell","patterns":[{"include":"#case_statement_context"}]},{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.character-class.shell"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.character-class.shell"}},"name":"string.regexp.character-class.shell","patterns":[{"match":"\\\\\\\\.","name":"constant.character.escape.shell"}]},{"include":"#string"},{"match":"[^\\\\t\\\\n )*?@\\\\[|]","name":"string.unquoted.pattern.shell string.regexp.unquoted.shell"}]},"command_name_range":{"begin":"\\\\G","beginCaptures":{},"end":"(?=[\\\\t \\\\&;|]|$|[\\\\n)\`])|(?=<)","endCaptures":{},"name":"meta.statement.command.name.shell","patterns":[{"match":"(?<!\\\\w)(?:continue|return|break)(?!\\\\w)","name":"entity.name.function.call.shell entity.name.command.shell keyword.control.$0.shell"},{"match":"(?<!\\\\w)(?:unfunction|continue|autoload|unsetopt|bindkey|builtin|getopts|command|declare|unalias|history|unlimit|typeset|suspend|source|printf|unhash|disown|ulimit|return|which|alias|break|false|print|shift|times|umask|unset|read|type|exec|eval|wait|echo|dirs|jobs|kill|hash|stat|exit|test|trap|true|let|set|pwd|cd|fg|bg|fc|[.:])(?!/)(?!\\\\w)(?!-)","name":"entity.name.function.call.shell entity.name.command.shell support.function.builtin.shell"},{"include":"#variable"},{"captures":{"1":{"name":"entity.name.function.call.shell entity.name.command.shell"}},"match":"(?<!\\\\w)(?<=\\\\G|[\\"')}])([^\\\\t\\\\n\\\\r \\"\\\\&');->\`{|]+)"},{"begin":"(?:\\\\G|(?<![\\\\t\\\\n #\\\\&;{|]))(\\\\$?)((\\")|('))","beginCaptures":{"1":{"name":"meta.statement.command.name.quoted.shell punctuation.definition.string.shell entity.name.function.call.shell entity.name.command.shell"},"2":{},"3":{"name":"meta.statement.command.name.quoted.shell string.quoted.double.shell punctuation.definition.string.begin.shell entity.name.function.call.shell entity.name.command.shell"},"4":{"name":"meta.statement.command.name.quoted.shell string.quoted.single.shell punctuation.definition.string.begin.shell entity.name.function.call.shell entity.name.command.shell"}},"end":"(?<!\\\\G)(?<=\\\\2)","endCaptures":{},"patterns":[{"include":"#continuation_of_single_quoted_command_name"},{"include":"#continuation_of_double_quoted_command_name"}]},{"include":"#line_continuation"},{"include":"#simple_unquoted"}]},"command_statement":{"begin":"[\\\\t ]*+(?![\\\\n!#\\\\&()<>\\\\[{|]|$|[\\\\t ;])(?!nocorrect |nocorrect\\\\t|nocorrect$|readonly |readonly\\\\t|readonly$|function |function\\\\t|function$|foreach |foreach\\\\t|foreach$|coproc |coproc\\\\t|coproc$|logout |logout\\\\t|logout$|export |export\\\\t|export$|select |select\\\\t|select$|repeat |repeat\\\\t|repeat$|pushd |pushd\\\\t|pushd$|until |until\\\\t|until$|while |while\\\\t|while$|local |local\\\\t|local$|case |case\\\\t|case$|done |done\\\\t|done$|elif |elif\\\\t|elif$|else |else\\\\t|else$|esac |esac\\\\t|esac$|popd |popd\\\\t|popd$|then |then\\\\t|then$|time |time\\\\t|time$|for |for\\\\t|for$|end |end\\\\t|end$|fi |fi\\\\t|fi$|do |do\\\\t|do$|in |in\\\\t|in$|if |if\\\\t|if$)(?!\\\\\\\\\\\\n?$)","beginCaptures":{},"end":"(?=[\\\\n\\\\&);\`{|}]|[\\\\t ]*#|])(?<!\\\\\\\\)","endCaptures":{},"name":"meta.statement.command.shell","patterns":[{"include":"#command_name_range"},{"include":"#line_continuation"},{"include":"#option"},{"include":"#argument"},{"include":"#string"},{"include":"#heredoc"}]},"comment":{"captures":{"1":{"name":"comment.line.number-sign.shell meta.shebang.shell"},"2":{"name":"punctuation.definition.comment.shebang.shell"},"3":{"name":"comment.line.number-sign.shell"},"4":{"name":"punctuation.definition.comment.shell"}},"match":"(?:^|[\\\\t ]++)(?:((#!).*)|((#).*))"},"comments":{"patterns":[{"include":"#block_comment"},{"include":"#line_comment"}]},"compound-command":{"patterns":[{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"name":"meta.scope.logical-expression.shell","patterns":[{"include":"#logical-expression"},{"include":"#initial_context"}]},{"begin":"(?<=\\\\s|^)\\\\{(?=\\\\s|$)","beginCaptures":{"0":{"name":"punctuation.definition.group.shell"}},"end":"(?<=^|;)\\\\s*(})","endCaptures":{"1":{"name":"punctuation.definition.group.shell"}},"name":"meta.scope.group.shell","patterns":[{"include":"#initial_context"}]}]},"continuation_of_double_quoted_command_name":{"begin":"\\\\G(?<=\\")","beginCaptures":{},"contentName":"meta.statement.command.name.continuation string.quoted.double entity.name.function.call entity.name.command","end":"\\"","endCaptures":{"0":{"name":"string.quoted.double.shell punctuation.definition.string.end.shell entity.name.function.call.shell entity.name.command.shell"}},"patterns":[{"match":"\\\\\\\\[\\\\n\\"$\\\\\\\\\`]","name":"constant.character.escape.shell"},{"include":"#variable"},{"include":"#interpolation"}]},"continuation_of_single_quoted_command_name":{"begin":"\\\\G(?<=')","beginCaptures":{},"contentName":"meta.statement.command.name.continuation string.quoted.single entity.name.function.call entity.name.command","end":"'","endCaptures":{"0":{"name":"string.quoted.single.shell punctuation.definition.string.end.shell entity.name.function.call.shell entity.name.command.shell"}}},"custom_command_names":{"patterns":[]},"custom_commands":{"patterns":[]},"double_quote_context":{"patterns":[{"match":"\\\\\\\\[\\\\n\\"$\\\\\\\\\`]","name":"constant.character.escape.shell"},{"include":"#variable"},{"include":"#interpolation"}]},"double_quote_escape_char":{"match":"\\\\\\\\[\\\\n\\"$\\\\\\\\\`]","name":"constant.character.escape.shell"},"floating_keyword":{"patterns":[{"match":"(?<=^|[\\\\t \\\\&;])(?:then|elif|else|done|end|do|if|fi)(?=[\\\\t \\\\&;]|$)","name":"keyword.control.$0.shell"}]},"for_statement":{"patterns":[{"begin":"\\\\b(for)\\\\b[\\\\t ]*+((?<!\\\\w)[-0-9A-Z_a-z]+(?!\\\\w))[\\\\t ]*+\\\\b(in)\\\\b","beginCaptures":{"1":{"name":"keyword.control.for.shell"},"2":{"name":"variable.other.for.shell"},"3":{"name":"keyword.control.in.shell"}},"end":"(?=[\\\\n\\\\&);\`{|}]|[\\\\t ]*#|])(?<!\\\\\\\\)","endCaptures":{},"name":"meta.for.in.shell","patterns":[{"include":"#string"},{"include":"#simple_unquoted"},{"include":"#normal_context"}]},{"begin":"\\\\b(for)\\\\b","beginCaptures":{"1":{"name":"keyword.control.for.shell"}},"end":"(?=[\\\\n\\\\&);\`{|}]|[\\\\t ]*#|])(?<!\\\\\\\\)","endCaptures":{},"name":"meta.for.shell","patterns":[{"include":"#arithmetic_double"},{"include":"#normal_context"}]}]},"function_definition":{"applyEndPatternLast":1,"begin":"[\\\\t ]*+(?:\\\\b(function)\\\\b[\\\\t ]*+([^\\\\t\\\\n\\\\r \\"'()=]+)(?:(\\\\()[\\\\t ]*+(\\\\)))?|([^\\\\t\\\\n\\\\r \\"'()=]+)[\\\\t ]*+(\\\\()[\\\\t ]*+(\\\\)))","beginCaptures":{"1":{"name":"storage.type.function.shell"},"2":{"name":"entity.name.function.shell"},"3":{"name":"punctuation.definition.arguments.shell"},"4":{"name":"punctuation.definition.arguments.shell"},"5":{"name":"entity.name.function.shell"},"6":{"name":"punctuation.definition.arguments.shell"},"7":{"name":"punctuation.definition.arguments.shell"}},"end":"(?<=[)}])","endCaptures":{},"name":"meta.function.shell","patterns":[{"match":"\\\\G[\\\\t\\\\n ]"},{"begin":"\\\\{","beginCaptures":{"0":{"name":"punctuation.definition.group.shell punctuation.section.function.definition.shell"}},"end":"}","endCaptures":{"0":{"name":"punctuation.definition.group.shell punctuation.section.function.definition.shell"}},"name":"meta.function.body.shell","patterns":[{"include":"#initial_context"}]},{"begin":"\\\\(","beginCaptures":{"0":{"name":"punctuation.definition.group.shell punctuation.section.function.definition.shell"}},"end":"\\\\)","endCaptures":{"0":{"name":"punctuation.definition.group.shell punctuation.section.function.definition.shell"}},"name":"meta.function.body.shell","patterns":[{"include":"#initial_context"}]},{"include":"#initial_context"}]},"heredoc":{"patterns":[{"begin":"((?<!<)<<-)[\\\\t ]*+([\\"'])[\\\\t ]*+([^\\"']+?)(?=[\\"\\\\&';<\\\\s])(\\\\2)(.*)","beginCaptures":{"1":{"name":"keyword.operator.heredoc.shell"},"2":{"name":"punctuation.definition.string.heredoc.quote.shell"},"3":{"name":"punctuation.definition.string.heredoc.delimiter.shell"},"4":{"name":"punctuation.definition.string.heredoc.quote.shell"},"5":{"patterns":[{"include":"#redirect_fix"},{"include":"#typical_statements"}]}},"contentName":"string.quoted.heredoc.indent.$3","end":"^\\\\t*\\\\3(?=[\\\\&;\\\\s]|$)","endCaptures":{"0":{"name":"punctuation.definition.string.heredoc.$0.shell"}},"patterns":[]},{"begin":"((?<!<)<<(?!<))[\\\\t ]*+([\\"'])[\\\\t ]*+([^\\"']+?)(?=[\\"\\\\&';<\\\\s])(\\\\2)(.*)","beginCaptures":{"1":{"name":"keyword.operator.heredoc.shell"},"2":{"name":"punctuation.definition.string.heredoc.quote.shell"},"3":{"name":"punctuation.definition.string.heredoc.delimiter.shell"},"4":{"name":"punctuation.definition.string.heredoc.quote.shell"},"5":{"patterns":[{"include":"#redirect_fix"},{"include":"#typical_statements"}]}},"contentName":"string.quoted.heredoc.no-indent.$3","end":"^\\\\3(?=[\\\\&;\\\\s]|$)","endCaptures":{"0":{"name":"punctuation.definition.string.heredoc.delimiter.shell"}},"patterns":[]},{"begin":"((?<!<)<<-)[\\\\t ]*+([^\\\\t \\"']+)(?=[\\"\\\\&';<\\\\s])(.*)","beginCaptures":{"1":{"name":"keyword.operator.heredoc.shell"},"2":{"name":"punctuation.definition.string.heredoc.delimiter.shell"},"3":{"patterns":[{"include":"#redirect_fix"},{"include":"#typical_statements"}]}},"contentName":"string.unquoted.heredoc.indent.$2","end":"^\\\\t*\\\\2(?=[\\\\&;\\\\s]|$)","endCaptures":{"0":{"name":"punctuation.definition.string.heredoc.delimiter.shell"}},"patterns":[{"include":"#double_quote_escape_char"},{"include":"#variable"},{"include":"#interpolation"}]},{"begin":"((?<!<)<<(?!<))[\\\\t ]*+([^\\\\t \\"']+)(?=[\\"\\\\&';<\\\\s])(.*)","beginCaptures":{"1":{"name":"keyword.operator.heredoc.shell"},"2":{"name":"punctuation.definition.string.heredoc.delimiter.shell"},"3":{"patterns":[{"include":"#redirect_fix"},{"include":"#typical_statements"}]}},"contentName":"string.unquoted.heredoc.no-indent.$2","end":"^\\\\2(?=[\\\\&;\\\\s]|$)","endCaptures":{"0":{"name":"punctuation.definition.string.heredoc.delimiter.shell"}},"patterns":[{"include":"#double_quote_escape_char"},{"include":"#variable"},{"include":"#interpolation"}]}]},"herestring":{"patterns":[{"begin":"(<<<)\\\\s*(('))","beginCaptures":{"1":{"name":"keyword.operator.herestring.shell"},"2":{"name":"string.quoted.single.shell"},"3":{"name":"punctuation.definition.string.begin.shell"}},"contentName":"string.quoted.single.shell","end":"(')","endCaptures":{"0":{"name":"string.quoted.single.shell"},"1":{"name":"punctuation.definition.string.end.shell"}},"name":"meta.herestring.shell"},{"begin":"(<<<)\\\\s*((\\"))","beginCaptures":{"1":{"name":"keyword.operator.herestring.shell"},"2":{"name":"string.quoted.double.shell"},"3":{"name":"punctuation.definition.string.begin.shell"}},"contentName":"string.quoted.double.shell","end":"(\\")","endCaptures":{"0":{"name":"string.quoted.double.shell"},"1":{"name":"punctuation.definition.string.end.shell"}},"name":"meta.herestring.shell","patterns":[{"include":"#double_quote_context"}]},{"captures":{"1":{"name":"keyword.operator.herestring.shell"},"2":{"name":"string.unquoted.herestring.shell","patterns":[{"include":"#initial_context"}]}},"match":"(<<<)\\\\s*(([^)\\\\\\\\\\\\s]|\\\\\\\\.)+)","name":"meta.herestring.shell"}]},"initial_context":{"patterns":[{"include":"#comment"},{"include":"#pipeline"},{"include":"#normal_statement_seperator"},{"include":"#logical_expression_double"},{"include":"#logical_expression_single"},{"include":"#assignment_statement"},{"include":"#case_statement"},{"include":"#for_statement"},{"include":"#loop"},{"include":"#function_definition"},{"include":"#line_continuation"},{"include":"#arithmetic_double"},{"include":"#misc_ranges"},{"include":"#variable"},{"include":"#interpolation"},{"include":"#heredoc"},{"include":"#herestring"},{"include":"#redirection"},{"include":"#pathname"},{"include":"#floating_keyword"},{"include":"#alias_statement"},{"include":"#normal_statement"},{"include":"#string"},{"include":"#support"}]},"inline_comment":{"captures":{"1":{"name":"comment.block.shell punctuation.definition.comment.begin.shell"},"2":{"name":"comment.block.shell"},"3":{"patterns":[{"match":"\\\\*/","name":"comment.block.shell punctuation.definition.comment.end.shell"},{"match":"\\\\*","name":"comment.block.shell"}]}},"match":"(/\\\\*)((?:[^*]|\\\\*++[^/])*+(\\\\*++/))"},"interpolation":{"patterns":[{"include":"#arithmetic_dollar"},{"include":"#subshell_dollar"},{"begin":"\`","beginCaptures":{"0":{"name":"punctuation.definition.evaluation.backticks.shell"}},"end":"\`","endCaptures":{"0":{"name":"punctuation.definition.evaluation.backticks.shell"}},"name":"string.interpolated.backtick.shell","patterns":[{"match":"\\\\\\\\[$\\\\\\\\\`]","name":"constant.character.escape.shell"},{"begin":"(?<=\\\\W)(?=#)(?!#\\\\{)","beginCaptures":{"1":{"name":"punctuation.whitespace.comment.leading.shell"}},"end":"(?!\\\\G)","patterns":[{"begin":"#","beginCaptures":{"0":{"name":"punctuation.definition.comment.shell"}},"end":"(?=\`)","name":"comment.line.number-sign.shell"}]},{"include":"#initial_context"}]}]},"keyword":{"patterns":[{"match":"(?<=^|[\\\\&;\\\\s])(then|else|elif|fi|for|in|do|done|select|continue|esac|while|until|return)(?=[\\\\&;\\\\s]|$)","name":"keyword.control.shell"},{"match":"(?<=^|[\\\\&;\\\\s])(?:export|declare|typeset|local|readonly)(?=[\\\\&;\\\\s]|$)","name":"storage.modifier.shell"}]},"line_comment":{"begin":"\\\\s*+(//)","beginCaptures":{"1":{"name":"punctuation.definition.comment.shell"}},"end":"(?<=\\\\n)(?<!\\\\\\\\\\\\n)","endCaptures":{},"name":"comment.line.double-slash.shell","patterns":[{"include":"#line_continuation_character"}]},"line_continuation":{"match":"\\\\\\\\(?=\\\\n)","name":"constant.character.escape.line-continuation.shell"},"logical-expression":{"patterns":[{"include":"#arithmetic_no_dollar"},{"match":"=[=~]?|!=?|[<>]|&&|\\\\|\\\\|","name":"keyword.operator.logical.shell"},{"match":"(?<!\\\\S)-(nt|ot|ef|eq|ne|l[et]|g[et]|[GLNOSa-hknopr-uwxz])\\\\b","name":"keyword.operator.logical.shell"}]},"logical_expression_context":{"patterns":[{"include":"#regex_comparison"},{"include":"#arithmetic_no_dollar"},{"include":"#logical-expression"},{"include":"#logical_expression_single"},{"include":"#logical_expression_double"},{"include":"#comment"},{"include":"#boolean"},{"include":"#redirect_number"},{"include":"#numeric_literal"},{"include":"#pipeline"},{"include":"#normal_statement_seperator"},{"include":"#string"},{"include":"#variable"},{"include":"#interpolation"},{"include":"#heredoc"},{"include":"#herestring"},{"include":"#pathname"},{"include":"#floating_keyword"},{"include":"#support"}]},"logical_expression_double":{"begin":"\\\\[\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"end":"]]","endCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"name":"meta.scope.logical-expression.shell","patterns":[{"include":"#logical_expression_context"}]},"logical_expression_single":{"begin":"\\\\[","beginCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"end":"]","endCaptures":{"0":{"name":"punctuation.definition.logical-expression.shell"}},"name":"meta.scope.logical-expression.shell","patterns":[{"include":"#logical_expression_context"}]},"loop":{"patterns":[{"begin":"(?<=^|[\\\\&;\\\\s])(for)\\\\s+(.+?)\\\\s+(in)(?=[\\\\&;\\\\s]|$)","beginCaptures":{"1":{"name":"keyword.control.shell"},"2":{"name":"variable.other.loop.shell","patterns":[{"include":"#string"}]},"3":{"name":"keyword.control.shell"}},"end":"(?<=^|[\\\\&;\\\\s])done(?=[\\\\&;\\\\s]|$|\\\\))","endCaptures":{"0":{"name":"keyword.control.shell"}},"name":"meta.scope.for-in-loop.shell","patterns":[{"include":"#initial_context"}]},{"begin":"(?<=^|[\\\\&;\\\\s])(while|until)(?=[\\\\&;\\\\s]|$)","beginCaptures":{"1":{"name":"keyword.control.shell"}},"end":"(?<=^|[\\\\&;\\\\s])done(?=[\\\\&;\\\\s]|$|\\\\))","endCaptures":{"0":{"name":"keyword.control.shell"}},"name":"meta.scope.while-loop.shell","patterns":[{"include":"#initial_context"}]},{"begin":"(?<=^|[\\\\&;\\\\s])(select)\\\\s+((?:[^\\\\\\\\\\\\s]|\\\\\\\\.)+)(?=[\\\\&;\\\\s]|$)","beginCaptures":{"1":{"name":"keyword.control.shell"},"2":{"name":"variable.other.loop.shell"}},"end":"(?<=^|[\\\\&;\\\\s])(done)(?=[\\\\&;\\\\s]|$|\\\\))","endCaptures":{"1":{"name":"keyword.control.shell"}},"name":"meta.scope.select-block.shell","patterns":[{"include":"#initial_context"}]},{"begin":"(?<=^|[\\\\&;\\\\s])if(?=[\\\\&;\\\\s]|$)","beginCaptures":{"0":{"name":"keyword.control.if.shell"}},"end":"(?<=^|[\\\\&;\\\\s])fi(?=[\\\\&;\\\\s]|$)","endCaptures":{"0":{"name":"keyword.control.fi.shell"}},"name":"meta.scope.if-block.shell","patterns":[{"include":"#initial_context"}]}]},"math":{"patterns":[{"include":"#variable"},{"match":"\\\\+{1,2}|-{1,2}|[!~]|\\\\*{1,2}|[%/]|<[<=]?|>[=>]?|==|!=|^|\\\\|{1,2}|&{1,2}|[,:=?]|[-%\\\\&*+/^|]=|<<=|>>=","name":"keyword.operator.arithmetic.shell"},{"match":"0[Xx]\\\\h+","name":"constant.numeric.hex.shell"},{"match":";","name":"punctuation.separator.semicolon.range"},{"match":"0\\\\d+","name":"constant.numeric.octal.shell"},{"match":"\\\\d{1,2}#[0-9@-Z_a-z]+","name":"constant.numeric.other.shell"},{"match":"\\\\d+","name":"constant.numeric.integer.shell"},{"match":"(?<!\\\\w)[0-9A-Z_a-z]+(?!\\\\w)","name":"variable.other.normal.shell"}]},"math_operators":{"patterns":[{"match":"\\\\+{1,2}|-{1,2}|[!~]|\\\\*{1,2}|[%/]|<[<=]?|>[=>]?|==|!=|^|\\\\|{1,2}|&{1,2}|[,:=?]|[-%\\\\&*+/^|]=|<<=|>>=","name":"keyword.operator.arithmetic.shell"},{"match":"0[Xx]\\\\h+","name":"constant.numeric.hex.shell"},{"match":"0\\\\d+","name":"constant.numeric.octal.shell"},{"match":"\\\\d{1,2}#[0-9@-Z_a-z]+","name":"constant.numeric.other.shell"},{"match":"\\\\d+","name":"constant.numeric.integer.shell"}]},"misc_ranges":{"patterns":[{"include":"#logical_expression_single"},{"include":"#logical_expression_double"},{"include":"#subshell_dollar"},{"begin":"(?<![^\\\\t ])(\\\\{)(?![$\\\\w])","beginCaptures":{"1":{"name":"punctuation.definition.group.shell"}},"end":"}","endCaptures":{"0":{"name":"punctuation.definition.group.shell"}},"name":"meta.scope.group.shell","patter