/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var _ _create = Object . create ;
var _ _defProp = Object . defineProperty ;
var _ _defProps = Object . defineProperties ;
var _ _getOwnPropDesc = Object . getOwnPropertyDescriptor ;
var _ _getOwnPropDescs = Object . getOwnPropertyDescriptors ;
var _ _getOwnPropNames = Object . getOwnPropertyNames ;
var _ _getOwnPropSymbols = Object . getOwnPropertySymbols ;
var _ _getProtoOf = Object . getPrototypeOf ;
var _ _hasOwnProp = Object . prototype . hasOwnProperty ;
var _ _propIsEnum = Object . prototype . propertyIsEnumerable ;
var _ _defNormalProp = ( obj , key , value ) => key in obj ? _ _defProp ( obj , key , { enumerable : true , configurable : true , writable : true , value } ) : obj [ key ] = value ;
var _ _spreadValues = ( a , b ) => {
for ( var prop in b || ( b = { } ) )
if ( _ _hasOwnProp . call ( b , prop ) )
_ _defNormalProp ( a , prop , b [ prop ] ) ;
if ( _ _getOwnPropSymbols )
for ( var prop of _ _getOwnPropSymbols ( b ) ) {
if ( _ _propIsEnum . call ( b , prop ) )
_ _defNormalProp ( a , prop , b [ prop ] ) ;
}
return a ;
} ;
var _ _spreadProps = ( a , b ) => _ _defProps ( a , _ _getOwnPropDescs ( b ) ) ;
var _ _commonJS = ( cb , mod ) => function _ _require ( ) {
return mod || ( 0 , cb [ _ _getOwnPropNames ( cb ) [ 0 ] ] ) ( ( mod = { exports : { } } ) . exports , mod ) , mod . exports ;
} ;
var _ _export = ( target , all ) => {
for ( var name in all )
_ _defProp ( target , name , { get : all [ name ] , enumerable : true } ) ;
} ;
var _ _copyProps = ( to , from , except , desc ) => {
if ( from && typeof from === "object" || typeof from === "function" ) {
for ( let key of _ _getOwnPropNames ( from ) )
if ( ! _ _hasOwnProp . call ( to , key ) && key !== except )
_ _defProp ( to , key , { get : ( ) => from [ key ] , enumerable : ! ( desc = _ _getOwnPropDesc ( from , key ) ) || desc . enumerable } ) ;
}
return to ;
} ;
var _ _toESM = ( mod , isNodeMode , target ) => ( target = mod != null ? _ _create ( _ _getProtoOf ( mod ) ) : { } , _ _copyProps ( isNodeMode || ! mod || ! mod . _ _esModule ? _ _defProp ( target , "default" , { value : mod , enumerable : true } ) : target , mod ) ) ;
var _ _toCommonJS = ( mod ) => _ _copyProps ( _ _defProp ( { } , "__esModule" , { value : true } ) , mod ) ;
var _ _async = ( _ _this , _ _arguments , generator ) => {
return new Promise ( ( resolve , reject ) => {
var fulfilled = ( value ) => {
try {
step ( generator . next ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var rejected = ( value ) => {
try {
step ( generator . throw ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
} ;
var step = ( x ) => x . done ? resolve ( x . value ) : Promise . resolve ( x . value ) . then ( fulfilled , rejected ) ;
step ( ( generator = generator . apply ( _ _this , _ _arguments ) ) . next ( ) ) ;
} ) ;
} ;
// node_modules/tslib/tslib.js
var require _tslib = _ _commonJS ( {
"node_modules/tslib/tslib.js" ( exports , module2 ) {
var _ _extends2 ;
var _ _assign2 ;
var _ _rest2 ;
var _ _decorate2 ;
var _ _param2 ;
var _ _metadata2 ;
var _ _awaiter2 ;
var _ _generator2 ;
var _ _exportStar2 ;
var _ _values2 ;
var _ _read2 ;
var _ _spread2 ;
var _ _spreadArrays2 ;
var _ _spreadArray2 ;
var _ _await2 ;
var _ _asyncGenerator2 ;
var _ _asyncDelegator2 ;
var _ _asyncValues2 ;
var _ _makeTemplateObject2 ;
var _ _importStar2 ;
var _ _importDefault2 ;
var _ _classPrivateFieldGet2 ;
var _ _classPrivateFieldSet2 ;
var _ _classPrivateFieldIn2 ;
var _ _createBinding2 ;
( function ( factory ) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : { } ;
if ( typeof define === "function" && define . amd ) {
define ( "tslib" , [ "exports" ] , function ( exports2 ) {
factory ( createExporter ( root , createExporter ( exports2 ) ) ) ;
} ) ;
} else if ( typeof module2 === "object" && typeof module2 . exports === "object" ) {
factory ( createExporter ( root , createExporter ( module2 . exports ) ) ) ;
} else {
factory ( createExporter ( root ) ) ;
}
function createExporter ( exports2 , previous ) {
if ( exports2 !== root ) {
if ( typeof Object . create === "function" ) {
Object . defineProperty ( exports2 , "__esModule" , { value : true } ) ;
} else {
exports2 . _ _esModule = true ;
}
}
return function ( id , v ) {
return exports2 [ id ] = previous ? previous ( id , v ) : v ;
} ;
}
} ) ( function ( exporter ) {
var extendStatics = Object . setPrototypeOf || { _ _proto _ _ : [ ] } instanceof Array && function ( d , b ) {
d . _ _proto _ _ = b ;
} || function ( d , b ) {
for ( var p in b )
if ( Object . prototype . hasOwnProperty . call ( b , p ) )
d [ p ] = b [ p ] ;
} ;
_ _extends2 = function ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) {
this . constructor = d ;
}
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
} ;
_ _assign2 = Object . assign || function ( t ) {
for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
s = arguments [ i ] ;
for ( var p in s )
if ( Object . prototype . hasOwnProperty . call ( s , p ) )
t [ p ] = s [ p ] ;
}
return t ;
} ;
_ _rest2 = function ( s , e ) {
var t = { } ;
for ( var p in s )
if ( Object . prototype . hasOwnProperty . call ( s , p ) && e . indexOf ( p ) < 0 )
t [ p ] = s [ p ] ;
if ( s != null && typeof Object . getOwnPropertySymbols === "function" )
for ( var i = 0 , p = Object . getOwnPropertySymbols ( s ) ; i < p . length ; i ++ ) {
if ( e . indexOf ( p [ i ] ) < 0 && Object . prototype . propertyIsEnumerable . call ( s , p [ i ] ) )
t [ p [ i ] ] = s [ p [ i ] ] ;
}
return t ;
} ;
_ _decorate2 = function ( decorators , target , key , desc ) {
var c = arguments . length , r = c < 3 ? target : desc === null ? desc = Object . getOwnPropertyDescriptor ( target , key ) : desc , d ;
if ( typeof Reflect === "object" && typeof Reflect . decorate === "function" )
r = Reflect . decorate ( decorators , target , key , desc ) ;
else
for ( var i = decorators . length - 1 ; i >= 0 ; i -- )
if ( d = decorators [ i ] )
r = ( c < 3 ? d ( r ) : c > 3 ? d ( target , key , r ) : d ( target , key ) ) || r ;
return c > 3 && r && Object . defineProperty ( target , key , r ) , r ;
} ;
_ _param2 = function ( paramIndex , decorator ) {
return function ( target , key ) {
decorator ( target , key , paramIndex ) ;
} ;
} ;
_ _metadata2 = function ( metadataKey , metadataValue ) {
if ( typeof Reflect === "object" && typeof Reflect . metadata === "function" )
return Reflect . metadata ( metadataKey , metadataValue ) ;
} ;
_ _awaiter2 = function ( thisArg , _arguments , P , generator ) {
function adopt ( value ) {
return value instanceof P ? value : new P ( function ( resolve ) {
resolve ( value ) ;
} ) ;
}
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) {
try {
step ( generator . next ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
}
function rejected ( value ) {
try {
step ( generator [ "throw" ] ( value ) ) ;
} catch ( e ) {
reject ( e ) ;
}
}
function step ( result ) {
result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ;
}
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
} ;
_ _generator2 = function ( thisArg , body ) {
var _ = { label : 0 , sent : function ( ) {
if ( t [ 0 ] & 1 )
throw t [ 1 ] ;
return t [ 1 ] ;
} , trys : [ ] , ops : [ ] } , f , y , t , g ;
return g = { next : verb ( 0 ) , "throw" : verb ( 1 ) , "return" : verb ( 2 ) } , typeof Symbol === "function" && ( g [ Symbol . iterator ] = function ( ) {
return this ;
} ) , g ;
function verb ( n ) {
return function ( v ) {
return step ( [ n , v ] ) ;
} ;
}
function step ( op ) {
if ( f )
throw new TypeError ( "Generator is already executing." ) ;
while ( _ )
try {
if ( f = 1 , y && ( t = op [ 0 ] & 2 ? y [ "return" ] : op [ 0 ] ? y [ "throw" ] || ( ( t = y [ "return" ] ) && t . call ( y ) , 0 ) : y . next ) && ! ( t = t . call ( y , op [ 1 ] ) ) . done )
return t ;
if ( y = 0 , t )
op = [ op [ 0 ] & 2 , t . value ] ;
switch ( op [ 0 ] ) {
case 0 :
case 1 :
t = op ;
break ;
case 4 :
_ . label ++ ;
return { value : op [ 1 ] , done : false } ;
case 5 :
_ . label ++ ;
y = op [ 1 ] ;
op = [ 0 ] ;
continue ;
case 7 :
op = _ . ops . pop ( ) ;
_ . trys . pop ( ) ;
continue ;
default :
if ( ! ( t = _ . trys , t = t . length > 0 && t [ t . length - 1 ] ) && ( op [ 0 ] === 6 || op [ 0 ] === 2 ) ) {
_ = 0 ;
continue ;
}
if ( op [ 0 ] === 3 && ( ! t || op [ 1 ] > t [ 0 ] && op [ 1 ] < t [ 3 ] ) ) {
_ . label = op [ 1 ] ;
break ;
}
if ( op [ 0 ] === 6 && _ . label < t [ 1 ] ) {
_ . label = t [ 1 ] ;
t = op ;
break ;
}
if ( t && _ . label < t [ 2 ] ) {
_ . label = t [ 2 ] ;
_ . ops . push ( op ) ;
break ;
}
if ( t [ 2 ] )
_ . ops . pop ( ) ;
_ . trys . pop ( ) ;
continue ;
}
op = body . call ( thisArg , _ ) ;
} catch ( e ) {
op = [ 6 , e ] ;
y = 0 ;
} finally {
f = t = 0 ;
}
if ( op [ 0 ] & 5 )
throw op [ 1 ] ;
return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
}
} ;
_ _exportStar2 = function ( m , o ) {
for ( var p in m )
if ( p !== "default" && ! Object . prototype . hasOwnProperty . call ( o , p ) )
_ _createBinding2 ( o , m , p ) ;
} ;
_ _createBinding2 = Object . create ? function ( o , m , k , k2 ) {
if ( k2 === void 0 )
k2 = k ;
var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
if ( ! desc || ( "get" in desc ? ! m . _ _esModule : desc . writable || desc . configurable ) ) {
desc = { enumerable : true , get : function ( ) {
return m [ k ] ;
} } ;
}
Object . defineProperty ( o , k2 , desc ) ;
} : function ( o , m , k , k2 ) {
if ( k2 === void 0 )
k2 = k ;
o [ k2 ] = m [ k ] ;
} ;
_ _values2 = function ( o ) {
var s = typeof Symbol === "function" && Symbol . iterator , m = s && o [ s ] , i = 0 ;
if ( m )
return m . call ( o ) ;
if ( o && typeof o . length === "number" )
return {
next : function ( ) {
if ( o && i >= o . length )
o = void 0 ;
return { value : o && o [ i ++ ] , done : ! o } ;
}
} ;
throw new TypeError ( s ? "Object is not iterable." : "Symbol.iterator is not defined." ) ;
} ;
_ _read2 = function ( o , n ) {
var m = typeof Symbol === "function" && o [ Symbol . iterator ] ;
if ( ! m )
return o ;
var i = m . call ( o ) , r , ar = [ ] , e ;
try {
while ( ( n === void 0 || n -- > 0 ) && ! ( r = i . next ( ) ) . done )
ar . push ( r . value ) ;
} catch ( error ) {
e = { error } ;
} finally {
try {
if ( r && ! r . done && ( m = i [ "return" ] ) )
m . call ( i ) ;
} finally {
if ( e )
throw e . error ;
}
}
return ar ;
} ;
_ _spread2 = function ( ) {
for ( var ar = [ ] , i = 0 ; i < arguments . length ; i ++ )
ar = ar . concat ( _ _read2 ( arguments [ i ] ) ) ;
return ar ;
} ;
_ _spreadArrays2 = function ( ) {
for ( var s = 0 , i = 0 , il = arguments . length ; i < il ; i ++ )
s += arguments [ i ] . length ;
for ( var r = Array ( s ) , k = 0 , i = 0 ; i < il ; i ++ )
for ( var a = arguments [ i ] , j = 0 , jl = a . length ; j < jl ; j ++ , k ++ )
r [ k ] = a [ j ] ;
return r ;
} ;
_ _spreadArray2 = function ( to , from , pack ) {
if ( pack || arguments . length === 2 )
for ( var i = 0 , l = from . length , ar ; i < l ; i ++ ) {
if ( ar || ! ( i in from ) ) {
if ( ! ar )
ar = Array . prototype . slice . call ( from , 0 , i ) ;
ar [ i ] = from [ i ] ;
}
}
return to . concat ( ar || Array . prototype . slice . call ( from ) ) ;
} ;
_ _await2 = function ( v ) {
return this instanceof _ _await2 ? ( this . v = v , this ) : new _ _await2 ( v ) ;
} ;
_ _asyncGenerator2 = function ( thisArg , _arguments , generator ) {
if ( ! Symbol . asyncIterator )
throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var g = generator . apply ( thisArg , _arguments || [ ] ) , i , q = [ ] ;
return i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) {
return this ;
} , i ;
function verb ( n ) {
if ( g [ n ] )
i [ n ] = function ( v ) {
return new Promise ( function ( a , b ) {
q . push ( [ n , v , a , b ] ) > 1 || resume ( n , v ) ;
} ) ;
} ;
}
function resume ( n , v ) {
try {
step ( g [ n ] ( v ) ) ;
} catch ( e ) {
settle ( q [ 0 ] [ 3 ] , e ) ;
}
}
function step ( r ) {
r . value instanceof _ _await2 ? Promise . resolve ( r . value . v ) . then ( fulfill , reject ) : settle ( q [ 0 ] [ 2 ] , r ) ;
}
function fulfill ( value ) {
resume ( "next" , value ) ;
}
function reject ( value ) {
resume ( "throw" , value ) ;
}
function settle ( f , v ) {
if ( f ( v ) , q . shift ( ) , q . length )
resume ( q [ 0 ] [ 0 ] , q [ 0 ] [ 1 ] ) ;
}
} ;
_ _asyncDelegator2 = function ( o ) {
var i , p ;
return i = { } , verb ( "next" ) , verb ( "throw" , function ( e ) {
throw e ;
} ) , verb ( "return" ) , i [ Symbol . iterator ] = function ( ) {
return this ;
} , i ;
function verb ( n , f ) {
i [ n ] = o [ n ] ? function ( v ) {
return ( p = ! p ) ? { value : _ _await2 ( o [ n ] ( v ) ) , done : n === "return" } : f ? f ( v ) : v ;
} : f ;
}
} ;
_ _asyncValues2 = function ( o ) {
if ( ! Symbol . asyncIterator )
throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var m = o [ Symbol . asyncIterator ] , i ;
return m ? m . call ( o ) : ( o = typeof _ _values2 === "function" ? _ _values2 ( o ) : o [ Symbol . iterator ] ( ) , i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) {
return this ;
} , i ) ;
function verb ( n ) {
i [ n ] = o [ n ] && function ( v ) {
return new Promise ( function ( resolve , reject ) {
v = o [ n ] ( v ) , settle ( resolve , reject , v . done , v . value ) ;
} ) ;
} ;
}
function settle ( resolve , reject , d , v ) {
Promise . resolve ( v ) . then ( function ( v2 ) {
resolve ( { value : v2 , done : d } ) ;
} , reject ) ;
}
} ;
_ _makeTemplateObject2 = function ( cooked , raw ) {
if ( Object . defineProperty ) {
Object . defineProperty ( cooked , "raw" , { value : raw } ) ;
} else {
cooked . raw = raw ;
}
return cooked ;
} ;
var _ _setModuleDefault = Object . create ? function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} : function ( o , v ) {
o [ "default" ] = v ;
} ;
_ _importStar2 = function ( mod ) {
if ( mod && mod . _ _esModule )
return mod ;
var result = { } ;
if ( mod != null ) {
for ( var k in mod )
if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) )
_ _createBinding2 ( result , mod , k ) ;
}
_ _setModuleDefault ( result , mod ) ;
return result ;
} ;
_ _importDefault2 = function ( mod ) {
return mod && mod . _ _esModule ? mod : { "default" : mod } ;
} ;
_ _classPrivateFieldGet2 = function ( receiver , state , kind , f ) {
if ( kind === "a" && ! f )
throw new TypeError ( "Private accessor was defined without a getter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) )
throw new TypeError ( "Cannot read private member from an object whose class did not declare it" ) ;
return kind === "m" ? f : kind === "a" ? f . call ( receiver ) : f ? f . value : state . get ( receiver ) ;
} ;
_ _classPrivateFieldSet2 = function ( receiver , state , value , kind , f ) {
if ( kind === "m" )
throw new TypeError ( "Private method is not writable" ) ;
if ( kind === "a" && ! f )
throw new TypeError ( "Private accessor was defined without a setter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) )
throw new TypeError ( "Cannot write private member to an object whose class did not declare it" ) ;
return kind === "a" ? f . call ( receiver , value ) : f ? f . value = value : state . set ( receiver , value ) , value ;
} ;
_ _classPrivateFieldIn2 = function ( state , receiver ) {
if ( receiver === null || typeof receiver !== "object" && typeof receiver !== "function" )
throw new TypeError ( "Cannot use 'in' operator on non-object" ) ;
return typeof state === "function" ? receiver === state : state . has ( receiver ) ;
} ;
exporter ( "__extends" , _ _extends2 ) ;
exporter ( "__assign" , _ _assign2 ) ;
exporter ( "__rest" , _ _rest2 ) ;
exporter ( "__decorate" , _ _decorate2 ) ;
exporter ( "__param" , _ _param2 ) ;
exporter ( "__metadata" , _ _metadata2 ) ;
exporter ( "__awaiter" , _ _awaiter2 ) ;
exporter ( "__generator" , _ _generator2 ) ;
exporter ( "__exportStar" , _ _exportStar2 ) ;
exporter ( "__createBinding" , _ _createBinding2 ) ;
exporter ( "__values" , _ _values2 ) ;
exporter ( "__read" , _ _read2 ) ;
exporter ( "__spread" , _ _spread2 ) ;
exporter ( "__spreadArrays" , _ _spreadArrays2 ) ;
exporter ( "__spreadArray" , _ _spreadArray2 ) ;
exporter ( "__await" , _ _await2 ) ;
exporter ( "__asyncGenerator" , _ _asyncGenerator2 ) ;
exporter ( "__asyncDelegator" , _ _asyncDelegator2 ) ;
exporter ( "__asyncValues" , _ _asyncValues2 ) ;
exporter ( "__makeTemplateObject" , _ _makeTemplateObject2 ) ;
exporter ( "__importStar" , _ _importStar2 ) ;
exporter ( "__importDefault" , _ _importDefault2 ) ;
exporter ( "__classPrivateFieldGet" , _ _classPrivateFieldGet2 ) ;
exporter ( "__classPrivateFieldSet" , _ _classPrivateFieldSet2 ) ;
exporter ( "__classPrivateFieldIn" , _ _classPrivateFieldIn2 ) ;
} ) ;
}
} ) ;
// src/main.ts
var main _exports = { } ;
_ _export ( main _exports , {
default : ( ) => PodNotes
} ) ;
module . exports = _ _toCommonJS ( main _exports ) ;
// node_modules/svelte/internal/index.mjs
function noop ( ) {
}
function assign ( tar , src ) {
for ( const k in src )
tar [ k ] = src [ k ] ;
return tar ;
}
function is _promise ( value ) {
return value && typeof value === "object" && typeof value . then === "function" ;
}
function run ( fn ) {
return fn ( ) ;
}
function blank _object ( ) {
return /* @__PURE__ */ Object . create ( null ) ;
}
function run _all ( fns ) {
fns . forEach ( run ) ;
}
function is _function ( thing ) {
return typeof thing === "function" ;
}
function safe _not _equal ( a , b ) {
return a != a ? b == b : a !== b || ( a && typeof a === "object" || typeof a === "function" ) ;
}
var src _url _equal _anchor ;
function src _url _equal ( element _src , url ) {
if ( ! src _url _equal _anchor ) {
src _url _equal _anchor = document . createElement ( "a" ) ;
}
src _url _equal _anchor . href = url ;
return element _src === src _url _equal _anchor . href ;
}
function is _empty ( obj ) {
return Object . keys ( obj ) . length === 0 ;
}
function subscribe ( store , ... callbacks ) {
if ( store == null ) {
return noop ;
}
const unsub = store . subscribe ( ... callbacks ) ;
return unsub . unsubscribe ? ( ) => unsub . unsubscribe ( ) : unsub ;
}
function get _store _value ( store ) {
let value ;
subscribe ( store , ( _ ) => value = _ ) ( ) ;
return value ;
}
function component _subscribe ( component , store , callback ) {
component . $$ . on _destroy . push ( subscribe ( store , callback ) ) ;
}
function create _slot ( definition , ctx , $$scope , fn ) {
if ( definition ) {
const slot _ctx = get _slot _context ( definition , ctx , $$scope , fn ) ;
return definition [ 0 ] ( slot _ctx ) ;
}
}
function get _slot _context ( definition , ctx , $$scope , fn ) {
return definition [ 1 ] && fn ? assign ( $$scope . ctx . slice ( ) , definition [ 1 ] ( fn ( ctx ) ) ) : $$scope . ctx ;
}
function get _slot _changes ( definition , $$scope , dirty , fn ) {
if ( definition [ 2 ] && fn ) {
const lets = definition [ 2 ] ( fn ( dirty ) ) ;
if ( $$scope . dirty === void 0 ) {
return lets ;
}
if ( typeof lets === "object" ) {
const merged = [ ] ;
const len = Math . max ( $$scope . dirty . length , lets . length ) ;
for ( let i = 0 ; i < len ; i += 1 ) {
merged [ i ] = $$scope . dirty [ i ] | lets [ i ] ;
}
return merged ;
}
return $$scope . dirty | lets ;
}
return $$scope . dirty ;
}
function update _slot _base ( slot , slot _definition , ctx , $$scope , slot _changes , get _slot _context _fn ) {
if ( slot _changes ) {
const slot _context = get _slot _context ( slot _definition , ctx , $$scope , get _slot _context _fn ) ;
slot . p ( slot _context , slot _changes ) ;
}
}
function get _all _dirty _from _scope ( $$scope ) {
if ( $$scope . ctx . length > 32 ) {
const dirty = [ ] ;
const length = $$scope . ctx . length / 32 ;
for ( let i = 0 ; i < length ; i ++ ) {
dirty [ i ] = - 1 ;
}
return dirty ;
}
return - 1 ;
}
function null _to _empty ( value ) {
return value == null ? "" : value ;
}
var is _client = typeof window !== "undefined" ;
var raf = is _client ? ( cb ) => requestAnimationFrame ( cb ) : noop ;
var is _hydrating = false ;
function start _hydrating ( ) {
is _hydrating = true ;
}
function end _hydrating ( ) {
is _hydrating = false ;
}
function append ( target , node ) {
target . appendChild ( node ) ;
}
function append _styles ( target , style _sheet _id , styles ) {
const append _styles _to = get _root _for _style ( target ) ;
if ( ! append _styles _to . getElementById ( style _sheet _id ) ) {
const style = element ( "style" ) ;
style . id = style _sheet _id ;
style . textContent = styles ;
append _stylesheet ( append _styles _to , style ) ;
}
}
function get _root _for _style ( node ) {
if ( ! node )
return document ;
const root = node . getRootNode ? node . getRootNode ( ) : node . ownerDocument ;
if ( root && root . host ) {
return root ;
}
return node . ownerDocument ;
}
function append _stylesheet ( node , style ) {
append ( node . head || node , style ) ;
}
function insert ( target , node , anchor ) {
target . insertBefore ( node , anchor || null ) ;
}
function detach ( node ) {
node . parentNode . removeChild ( node ) ;
}
function destroy _each ( iterations , detaching ) {
for ( let i = 0 ; i < iterations . length ; i += 1 ) {
if ( iterations [ i ] )
iterations [ i ] . d ( detaching ) ;
}
}
function element ( name ) {
return document . createElement ( name ) ;
}
function text ( data ) {
return document . createTextNode ( data ) ;
}
function space ( ) {
return text ( " " ) ;
}
function empty ( ) {
return text ( "" ) ;
}
function listen ( node , event , handler , options ) {
node . addEventListener ( event , handler , options ) ;
return ( ) => node . removeEventListener ( event , handler , options ) ;
}
function prevent _default ( fn ) {
return function ( event ) {
event . preventDefault ( ) ;
return fn . call ( this , event ) ;
} ;
}
function attr ( node , attribute , value ) {
if ( value == null )
node . removeAttribute ( attribute ) ;
else if ( node . getAttribute ( attribute ) !== value )
node . setAttribute ( attribute , value ) ;
}
function children ( element2 ) {
return Array . from ( element2 . childNodes ) ;
}
function set _data ( text2 , data ) {
data = "" + data ;
if ( text2 . wholeText !== data )
text2 . data = data ;
}
function set _style ( node , key , value , important ) {
if ( value === null ) {
node . style . removeProperty ( key ) ;
} else {
node . style . setProperty ( key , value , important ? "important" : "" ) ;
}
}
function custom _event ( type , detail , { bubbles = false , cancelable = false } = { } ) {
const e = document . createEvent ( "CustomEvent" ) ;
e . initCustomEvent ( type , bubbles , cancelable , detail ) ;
return e ;
}
var current _component ;
function set _current _component ( component ) {
current _component = component ;
}
function get _current _component ( ) {
if ( ! current _component )
throw new Error ( "Function called outside component initialization" ) ;
return current _component ;
}
function onMount ( fn ) {
get _current _component ( ) . $$ . on _mount . push ( fn ) ;
}
function afterUpdate ( fn ) {
get _current _component ( ) . $$ . after _update . push ( fn ) ;
}
function onDestroy ( fn ) {
get _current _component ( ) . $$ . on _destroy . push ( fn ) ;
}
function createEventDispatcher ( ) {
const component = get _current _component ( ) ;
return ( type , detail , { cancelable = false } = { } ) => {
const callbacks = component . $$ . callbacks [ type ] ;
if ( callbacks ) {
const event = custom _event ( type , detail , { cancelable } ) ;
callbacks . slice ( ) . forEach ( ( fn ) => {
fn . call ( component , event ) ;
} ) ;
return ! event . defaultPrevented ;
}
return true ;
} ;
}
function bubble ( component , event ) {
const callbacks = component . $$ . callbacks [ event . type ] ;
if ( callbacks ) {
callbacks . slice ( ) . forEach ( ( fn ) => fn . call ( this , event ) ) ;
}
}
var dirty _components = [ ] ;
var binding _callbacks = [ ] ;
var render _callbacks = [ ] ;
var flush _callbacks = [ ] ;
var resolved _promise = Promise . resolve ( ) ;
var update _scheduled = false ;
function schedule _update ( ) {
if ( ! update _scheduled ) {
update _scheduled = true ;
resolved _promise . then ( flush ) ;
}
}
function add _render _callback ( fn ) {
render _callbacks . push ( fn ) ;
}
function add _flush _callback ( fn ) {
flush _callbacks . push ( fn ) ;
}
var seen _callbacks = /* @__PURE__ */ new Set ( ) ;
var flushidx = 0 ;
function flush ( ) {
const saved _component = current _component ;
do {
while ( flushidx < dirty _components . length ) {
const component = dirty _components [ flushidx ] ;
flushidx ++ ;
set _current _component ( component ) ;
update ( component . $$ ) ;
}
set _current _component ( null ) ;
dirty _components . length = 0 ;
flushidx = 0 ;
while ( binding _callbacks . length )
binding _callbacks . pop ( ) ( ) ;
for ( let i = 0 ; i < render _callbacks . length ; i += 1 ) {
const callback = render _callbacks [ i ] ;
if ( ! seen _callbacks . has ( callback ) ) {
seen _callbacks . add ( callback ) ;
callback ( ) ;
}
}
render _callbacks . length = 0 ;
} while ( dirty _components . length ) ;
while ( flush _callbacks . length ) {
flush _callbacks . pop ( ) ( ) ;
}
update _scheduled = false ;
seen _callbacks . clear ( ) ;
set _current _component ( saved _component ) ;
}
function update ( $$ ) {
if ( $$ . fragment !== null ) {
$$ . update ( ) ;
run _all ( $$ . before _update ) ;
const dirty = $$ . dirty ;
$$ . dirty = [ - 1 ] ;
$$ . fragment && $$ . fragment . p ( $$ . ctx , dirty ) ;
$$ . after _update . forEach ( add _render _callback ) ;
}
}
var outroing = /* @__PURE__ */ new Set ( ) ;
var outros ;
function group _outros ( ) {
outros = {
r : 0 ,
c : [ ] ,
p : outros
} ;
}
function check _outros ( ) {
if ( ! outros . r ) {
run _all ( outros . c ) ;
}
outros = outros . p ;
}
function transition _in ( block , local ) {
if ( block && block . i ) {
outroing . delete ( block ) ;
block . i ( local ) ;
}
}
function transition _out ( block , local , detach2 , callback ) {
if ( block && block . o ) {
if ( outroing . has ( block ) )
return ;
outroing . add ( block ) ;
outros . c . push ( ( ) => {
outroing . delete ( block ) ;
if ( callback ) {
if ( detach2 )
block . d ( 1 ) ;
callback ( ) ;
}
} ) ;
block . o ( local ) ;
} else if ( callback ) {
callback ( ) ;
}
}
function handle _promise ( promise , info ) {
const token = info . token = { } ;
function update2 ( type , index , key , value ) {
if ( info . token !== token )
return ;
info . resolved = value ;
let child _ctx = info . ctx ;
if ( key !== void 0 ) {
child _ctx = child _ctx . slice ( ) ;
child _ctx [ key ] = value ;
}
const block = type && ( info . current = type ) ( child _ctx ) ;
let needs _flush = false ;
if ( info . block ) {
if ( info . blocks ) {
info . blocks . forEach ( ( block2 , i ) => {
if ( i !== index && block2 ) {
group _outros ( ) ;
transition _out ( block2 , 1 , 1 , ( ) => {
if ( info . blocks [ i ] === block2 ) {
info . blocks [ i ] = null ;
}
} ) ;
check _outros ( ) ;
}
} ) ;
} else {
info . block . d ( 1 ) ;
}
block . c ( ) ;
transition _in ( block , 1 ) ;
block . m ( info . mount ( ) , info . anchor ) ;
needs _flush = true ;
}
info . block = block ;
if ( info . blocks )
info . blocks [ index ] = block ;
if ( needs _flush ) {
flush ( ) ;
}
}
if ( is _promise ( promise ) ) {
const current _component2 = get _current _component ( ) ;
promise . then ( ( value ) => {
set _current _component ( current _component2 ) ;
update2 ( info . then , 1 , info . value , value ) ;
set _current _component ( null ) ;
} , ( error ) => {
set _current _component ( current _component2 ) ;
update2 ( info . catch , 2 , info . error , error ) ;
set _current _component ( null ) ;
if ( ! info . hasCatch ) {
throw error ;
}
} ) ;
if ( info . current !== info . pending ) {
update2 ( info . pending , 0 ) ;
return true ;
}
} else {
if ( info . current !== info . then ) {
update2 ( info . then , 1 , info . value , promise ) ;
return true ;
}
info . resolved = promise ;
}
}
function update _await _block _branch ( info , ctx , dirty ) {
const child _ctx = ctx . slice ( ) ;
const { resolved } = info ;
if ( info . current === info . then ) {
child _ctx [ info . value ] = resolved ;
}
if ( info . current === info . catch ) {
child _ctx [ info . error ] = resolved ;
}
info . block . p ( child _ctx , dirty ) ;
}
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global ;
function bind ( component , name , callback ) {
const index = component . $$ . props [ name ] ;
if ( index !== void 0 ) {
component . $$ . bound [ index ] = callback ;
callback ( component . $$ . ctx [ index ] ) ;
}
}
function create _component ( block ) {
block && block . c ( ) ;
}
function mount _component ( component , target , anchor , customElement ) {
const { fragment , on _mount , on _destroy , after _update } = component . $$ ;
fragment && fragment . m ( target , anchor ) ;
if ( ! customElement ) {
add _render _callback ( ( ) => {
const new _on _destroy = on _mount . map ( run ) . filter ( is _function ) ;
if ( on _destroy ) {
on _destroy . push ( ... new _on _destroy ) ;
} else {
run _all ( new _on _destroy ) ;
}
component . $$ . on _mount = [ ] ;
} ) ;
}
after _update . forEach ( add _render _callback ) ;
}
function destroy _component ( component , detaching ) {
const $$ = component . $$ ;
if ( $$ . fragment !== null ) {
run _all ( $$ . on _destroy ) ;
$$ . fragment && $$ . fragment . d ( detaching ) ;
$$ . on _destroy = $$ . fragment = null ;
$$ . ctx = [ ] ;
}
}
function make _dirty ( component , i ) {
if ( component . $$ . dirty [ 0 ] === - 1 ) {
dirty _components . push ( component ) ;
schedule _update ( ) ;
component . $$ . dirty . fill ( 0 ) ;
}
component . $$ . dirty [ i / 31 | 0 ] |= 1 << i % 31 ;
}
function init ( component , options , instance23 , create _fragment24 , not _equal , props , append _styles2 , dirty = [ - 1 ] ) {
const parent _component = current _component ;
set _current _component ( component ) ;
const $$ = component . $$ = {
fragment : null ,
ctx : null ,
props ,
update : noop ,
not _equal ,
bound : blank _object ( ) ,
on _mount : [ ] ,
on _destroy : [ ] ,
on _disconnect : [ ] ,
before _update : [ ] ,
after _update : [ ] ,
context : new Map ( options . context || ( parent _component ? parent _component . $$ . context : [ ] ) ) ,
callbacks : blank _object ( ) ,
dirty ,
skip _bound : false ,
root : options . target || parent _component . $$ . root
} ;
append _styles2 && append _styles2 ( $$ . root ) ;
let ready = false ;
$$ . ctx = instance23 ? instance23 ( component , options . props || { } , ( i , ret , ... rest ) => {
const value = rest . length ? rest [ 0 ] : ret ;
if ( $$ . ctx && not _equal ( $$ . ctx [ i ] , $$ . ctx [ i ] = value ) ) {
if ( ! $$ . skip _bound && $$ . bound [ i ] )
$$ . bound [ i ] ( value ) ;
if ( ready )
make _dirty ( component , i ) ;
}
return ret ;
} ) : [ ] ;
$$ . update ( ) ;
ready = true ;
run _all ( $$ . before _update ) ;
$$ . fragment = create _fragment24 ? create _fragment24 ( $$ . ctx ) : false ;
if ( options . target ) {
if ( options . hydrate ) {
start _hydrating ( ) ;
const nodes = children ( options . target ) ;
$$ . fragment && $$ . fragment . l ( nodes ) ;
nodes . forEach ( detach ) ;
} else {
$$ . fragment && $$ . fragment . c ( ) ;
}
if ( options . intro )
transition _in ( component . $$ . fragment ) ;
mount _component ( component , options . target , options . anchor , options . customElement ) ;
end _hydrating ( ) ;
flush ( ) ;
}
set _current _component ( parent _component ) ;
}
var SvelteElement ;
if ( typeof HTMLElement === "function" ) {
SvelteElement = class extends HTMLElement {
constructor ( ) {
super ( ) ;
this . attachShadow ( { mode : "open" } ) ;
}
connectedCallback ( ) {
const { on _mount } = this . $$ ;
this . $$ . on _disconnect = on _mount . map ( run ) . filter ( is _function ) ;
for ( const key in this . $$ . slotted ) {
this . appendChild ( this . $$ . slotted [ key ] ) ;
}
}
attributeChangedCallback ( attr2 , _oldValue , newValue ) {
this [ attr2 ] = newValue ;
}
disconnectedCallback ( ) {
run _all ( this . $$ . on _disconnect ) ;
}
$destroy ( ) {
destroy _component ( this , 1 ) ;
this . $destroy = noop ;
}
$on ( type , callback ) {
const callbacks = this . $$ . callbacks [ type ] || ( this . $$ . callbacks [ type ] = [ ] ) ;
callbacks . push ( callback ) ;
return ( ) => {
const index = callbacks . indexOf ( callback ) ;
if ( index !== - 1 )
callbacks . splice ( index , 1 ) ;
} ;
}
$set ( $$props ) {
if ( this . $$set && ! is _empty ( $$props ) ) {
this . $$ . skip _bound = true ;
this . $$set ( $$props ) ;
this . $$ . skip _bound = false ;
}
}
} ;
}
var SvelteComponent = class {
$destroy ( ) {
destroy _component ( this , 1 ) ;
this . $destroy = noop ;
}
$on ( type , callback ) {
const callbacks = this . $$ . callbacks [ type ] || ( this . $$ . callbacks [ type ] = [ ] ) ;
callbacks . push ( callback ) ;
return ( ) => {
const index = callbacks . indexOf ( callback ) ;
if ( index !== - 1 )
callbacks . splice ( index , 1 ) ;
} ;
}
$set ( $$props ) {
if ( this . $$set && ! is _empty ( $$props ) ) {
this . $$ . skip _bound = true ;
this . $$set ( $$props ) ;
this . $$ . skip _bound = false ;
}
}
} ;
// node_modules/svelte/store/index.mjs
var subscriber _queue = [ ] ;
function writable ( value , start = noop ) {
let stop ;
const subscribers = /* @__PURE__ */ new Set ( ) ;
function set ( new _value ) {
if ( safe _not _equal ( value , new _value ) ) {
value = new _value ;
if ( stop ) {
const run _queue = ! subscriber _queue . length ;
for ( const subscriber of subscribers ) {
subscriber [ 1 ] ( ) ;
subscriber _queue . push ( subscriber , value ) ;
}
if ( run _queue ) {
for ( let i = 0 ; i < subscriber _queue . length ; i += 2 ) {
subscriber _queue [ i ] [ 0 ] ( subscriber _queue [ i + 1 ] ) ;
}
subscriber _queue . length = 0 ;
}
}
}
}
function update2 ( fn ) {
set ( fn ( value ) ) ;
}
function subscribe2 ( run2 , invalidate = noop ) {
const subscriber = [ run2 , invalidate ] ;
subscribers . add ( subscriber ) ;
if ( subscribers . size === 1 ) {
stop = start ( set ) || noop ;
}
run2 ( value ) ;
return ( ) => {
subscribers . delete ( subscriber ) ;
if ( subscribers . size === 0 ) {
stop ( ) ;
stop = null ;
}
} ;
}
return { set , update : update2 , subscribe : subscribe2 } ;
}
// src/store/index.ts
var import _obsidian = require ( "obsidian" ) ;
var plugin = writable ( ) ;
var currentTime = writable ( 0 ) ;
var duration = writable ( 0 ) ;
var currentEpisode = function ( ) {
const store = writable ( ) ;
const { subscribe : subscribe2 , update : update2 } = store ;
return {
subscribe : subscribe2 ,
update : update2 ,
set : ( newEpisode , addPrevToQueue = true ) => {
update2 ( ( previousEpisode ) => {
if ( previousEpisode ) {
if ( addPrevToQueue ) {
addEpisodeToQueue ( previousEpisode ) ;
}
const ct = get _store _value ( currentTime ) ;
const dur = get _store _value ( duration ) ;
const isFinished = ct === dur ;
playedEpisodes . setEpisodeTime ( previousEpisode , ct , dur , isFinished ) ;
}
return newEpisode ;
} ) ;
}
} ;
} ( ) ;
var isPaused = writable ( true ) ;
var playedEpisodes = function ( ) {
const store = writable ( { } ) ;
const { subscribe : subscribe2 , update : update2 , set } = store ;
return {
subscribe : subscribe2 ,
set ,
update : update2 ,
setEpisodeTime : ( episode , time , duration2 , finished ) => {
update2 ( ( playedEpisodes2 ) => {
playedEpisodes2 [ episode . title ] = {
title : episode . title ,
podcastName : episode . podcastName ,
time ,
duration : duration2 ,
finished
} ;
return playedEpisodes2 ;
} ) ;
} ,
markAsPlayed : ( episode ) => {
update2 ( ( playedEpisodes2 ) => {
const playedEpisode = playedEpisodes2 [ episode . title ] ;
if ( playedEpisode ) {
playedEpisode . time = playedEpisode . duration ;
playedEpisode . finished = true ;
}
playedEpisodes2 [ episode . title ] = playedEpisode ;
return playedEpisodes2 ;
} ) ;
} ,
markAsUnplayed : ( episode ) => {
update2 ( ( playedEpisodes2 ) => {
const playedEpisode = playedEpisodes2 [ episode . title ] ;
if ( playedEpisode ) {
playedEpisode . time = 0 ;
playedEpisode . finished = false ;
}
playedEpisodes2 [ episode . title ] = playedEpisode ;
return playedEpisodes2 ;
} ) ;
}
} ;
} ( ) ;
var savedFeeds = writable ( { } ) ;
var episodeCache = writable ( { } ) ;
var downloadedEpisodes = function ( ) {
const store = writable ( { } ) ;
const { subscribe : subscribe2 , update : update2 , set } = store ;
function isEpisodeDownloaded ( episode ) {
var _a ;
return ( _a = get _store _value ( store ) [ episode . podcastName ] ) == null ? void 0 : _a . some ( ( e ) => e . title === episode . title ) ;
}
return {
subscribe : subscribe2 ,
set ,
update : update2 ,
isEpisodeDownloaded ,
addEpisode : ( episode , filePath , size ) => {
update2 ( ( downloadedEpisodes2 ) => {
const podcastEpisodes = downloadedEpisodes2 [ episode . podcastName ] || [ ] ;
const idx = podcastEpisodes . findIndex ( ( ep ) => ep . title === episode . title ) ;
if ( idx !== - 1 ) {
podcastEpisodes [ idx ] = _ _spreadProps ( _ _spreadValues ( { } , episode ) , { filePath , size } ) ;
} else {
podcastEpisodes . push ( _ _spreadProps ( _ _spreadValues ( { } , episode ) , {
filePath ,
size
} ) ) ;
}
downloadedEpisodes2 [ episode . podcastName ] = podcastEpisodes ;
return downloadedEpisodes2 ;
} ) ;
} ,
removeEpisode : ( episode , removeFile ) => {
update2 ( ( downloadedEpisodes2 ) => {
const podcastEpisodes = downloadedEpisodes2 [ episode . podcastName ] || [ ] ;
const index = podcastEpisodes . findIndex ( ( e ) => e . title === episode . title ) ;
const filePath = podcastEpisodes [ index ] . filePath ;
podcastEpisodes . splice ( index , 1 ) ;
if ( removeFile ) {
try {
const file = app . vault . getAbstractFileByPath ( filePath ) ;
if ( file instanceof import _obsidian . TFile ) {
app . vault . delete ( file ) ;
}
} catch ( error ) {
console . error ( error ) ;
}
}
downloadedEpisodes2 [ episode . podcastName ] = podcastEpisodes ;
return downloadedEpisodes2 ;
} ) ;
} ,
getEpisode : ( episode ) => {
var _a ;
return ( _a = get _store _value ( store ) [ episode . podcastName ] ) == null ? void 0 : _a . find ( ( e ) => e . title === episode . title ) ;
}
} ;
} ( ) ;
var queue = function ( ) {
const store = writable ( {
icon : "list-ordered" ,
name : "Queue" ,
episodes : [ ] ,
shouldEpisodeRemoveAfterPlay : true ,
shouldRepeat : false
} ) ;
const { subscribe : subscribe2 , update : update2 , set } = store ;
return {
subscribe : subscribe2 ,
update : update2 ,
set ,
add : ( episode ) => {
update2 ( ( queue2 ) => {
queue2 . episodes . push ( episode ) ;
return queue2 ;
} ) ;
} ,
remove : ( episode ) => {
update2 ( ( queue2 ) => {
queue2 . episodes = queue2 . episodes . filter ( ( e ) => e . title !== episode . title ) ;
return queue2 ;
} ) ;
} ,
playNext : ( ) => {
update2 ( ( queue2 ) => {
const nextEp = queue2 . episodes . shift ( ) ;
if ( nextEp ) {
currentEpisode . set ( nextEp , false ) ;
}
return queue2 ;
} ) ;
}
} ;
} ( ) ;
var favorites = writable ( {
icon : "lucide-star" ,
name : "Favorites" ,
episodes : [ ] ,
shouldEpisodeRemoveAfterPlay : false ,
shouldRepeat : false
} ) ;
var localFiles = function ( ) {
const store = writable ( {
icon : "folder" ,
name : "Local Files" ,
episodes : [ ] ,
shouldEpisodeRemoveAfterPlay : false ,
shouldRepeat : false
} ) ;
const { subscribe : subscribe2 , update : update2 , set } = store ;
return {
subscribe : subscribe2 ,
update : update2 ,
set ,
getLocalEpisode : ( title ) => {
const ep = get _store _value ( store ) . episodes . find ( ( ep2 ) => ep2 . title === title ) ;
return ep ;
} ,
updateStreamUrl : ( title , newUrl ) => {
store . update ( ( playlist ) => {
const idx = playlist . episodes . findIndex ( ( ep ) => ep . title === title ) ;
if ( idx !== - 1 )
playlist . episodes [ idx ] . streamUrl = newUrl ;
return playlist ;
} ) ;
} ,
addEpisode : ( episode ) => {
store . update ( ( playlist ) => {
const idx = playlist . episodes . findIndex ( ( ep ) => ep . title === episode . title ) ;
if ( idx !== - 1 ) {
playlist . episodes [ idx ] = episode ;
} else {
playlist . episodes . push ( episode ) ;
}
return playlist ;
} ) ;
}
} ;
} ( ) ;
var playlists = writable ( { } ) ;
var podcastView = writable ( ) ;
var viewState = function ( ) {
const store = writable ( 0 /* PodcastGrid */ ) ;
const { subscribe : subscribe2 , set } = store ;
return {
subscribe : subscribe2 ,
set : ( newState ) => {
var _a ;
set ( newState ) ;
( _a = get _store _value ( podcastView ) ) == null ? void 0 : _a . scrollIntoView ( ) ;
}
} ;
} ( ) ;
function addEpisodeToQueue ( episode ) {
queue . update ( ( playlist ) => {
const newEpisodes = [ episode , ... playlist . episodes ] ;
playlist . episodes = newEpisodes ;
return playlist ;
} ) ;
}
// src/main.ts
var import _obsidian22 = require ( "obsidian" ) ;
// src/utility/formatSeconds.ts
function formatSeconds ( seconds , format2 ) {
return window . moment ( ) . startOf ( "day" ) . seconds ( seconds ) . format ( format2 ) ;
}
// src/utility/encodePodnotesURI.ts
function encodePodnotesURI ( title , feedUrl , time ) {
const url = new URL ( ` obsidian://podnotes ` ) ;
url . searchParams . set ( "episodeName" , title ) ;
url . searchParams . set ( "url" , feedUrl ) ;
if ( time ) {
url . searchParams . set ( "time" , time . toString ( ) ) ;
}
return url ;
}
// src/utility/isLocalFile.ts
function isLocalFile ( ep ) {
return ep . podcastName === "local file" ;
}
// src/API/API.ts
var API = class {
get podcast ( ) {
return get _store _value ( currentEpisode ) ;
}
get length ( ) {
return get _store _value ( duration ) ;
}
get currentTime ( ) {
return get _store _value ( currentTime ) ;
}
set currentTime ( value ) {
currentTime . update ( ( _ ) => value ) ;
}
get isPlaying ( ) {
return ! get _store _value ( isPaused ) ;
}
getPodcastTimeFormatted ( format2 , linkify = false ) {
var _a ;
if ( ! this . podcast ) {
throw new Error ( "No podcast loaded" ) ;
}
const time = formatSeconds ( this . currentTime , format2 ) ;
if ( ! linkify )
return time ;
const epIsLocal = isLocalFile ( this . podcast ) ;
const feedUrl = ! epIsLocal ? this . podcast . feedUrl : ( _a = downloadedEpisodes . getEpisode ( this . podcast ) ) == null ? void 0 : _a . filePath ;
if ( ! feedUrl || feedUrl === "" ) {
return time ;
}
const url = encodePodnotesURI ( this . podcast . title , feedUrl , this . currentTime ) ;
return ` [ ${ time } ]( ${ url . href } ) ` ;
}
start ( ) {
isPaused . update ( ( _ ) => false ) ;
}
stop ( ) {
isPaused . update ( ( _ ) => true ) ;
}
togglePlayback ( ) {
isPaused . update ( ( isPaused2 ) => ! isPaused2 ) ;
}
skipBackward ( ) {
const skipBackLen = get _store _value ( plugin ) . settings . skipBackwardLength ;
this . currentTime -= skipBackLen ;
}
skipForward ( ) {
const skipForwardLen = get _store _value ( plugin ) . settings . skipForwardLength ;
this . currentTime += skipForwardLen ;
}
} ;
// src/constants.ts
var VIEW _TYPE = "podcast_player_view" ;
var FAVORITES _SETTINGS = {
icon : "lucide-star" ,
name : "Favorites" ,
shouldEpisodeRemoveAfterPlay : false ,
shouldRepeat : false
} ;
var QUEUE _SETTINGS = {
icon : "list-ordered" ,
name : "Queue" ,
shouldEpisodeRemoveAfterPlay : true ,
shouldRepeat : false
} ;
var LOCAL _FILES _SETTINGS = {
icon : "folder" ,
name : "Local Files" ,
shouldEpisodeRemoveAfterPlay : false ,
shouldRepeat : false
} ;
var DEFAULT _SETTINGS = {
savedFeeds : { } ,
podNotes : { } ,
defaultPlaybackRate : 1 ,
playedEpisodes : { } ,
favorites : _ _spreadProps ( _ _spreadValues ( { } , FAVORITES _SETTINGS ) , {
episodes : [ ]
} ) ,
queue : _ _spreadProps ( _ _spreadValues ( { } , QUEUE _SETTINGS ) , {
episodes : [ ]
} ) ,
playlists : { } ,
skipBackwardLength : 15 ,
skipForwardLength : 15 ,
currentEpisode : void 0 ,
timestamp : {
template : "- {{time}} "
} ,
note : {
path : "" ,
template : ""
} ,
download : {
path : ""
} ,
downloadedEpisodes : { } ,
localFiles : _ _spreadProps ( _ _spreadValues ( { } , LOCAL _FILES _SETTINGS ) , {
episodes : [ ]
} )
} ;
// src/ui/settings/PodNotesSettingsTab.ts
var import _obsidian11 = require ( "obsidian" ) ;
// node_modules/tslib/modules/index.js
var import _tslib = _ _toESM ( require _tslib ( ) , 1 ) ;
var {
_ _extends ,
_ _assign ,
_ _rest ,
_ _decorate ,
_ _param ,
_ _metadata ,
_ _awaiter ,
_ _generator ,
_ _exportStar ,
_ _createBinding ,
_ _values ,
_ _read ,
_ _spread ,
_ _spreadArrays ,
_ _spreadArray ,
_ _await ,
_ _asyncGenerator ,
_ _asyncDelegator ,
_ _asyncValues ,
_ _makeTemplateObject ,
_ _importStar ,
_ _importDefault ,
_ _classPrivateFieldGet ,
_ _classPrivateFieldSet ,
_ _classPrivateFieldIn
} = import _tslib . default ;
// src/ui/settings/PodcastQueryGrid.svelte
var import _obsidian6 = require ( "obsidian" ) ;
// src/iTunesAPIConsumer.ts
var import _obsidian2 = require ( "obsidian" ) ;
function queryiTunesPodcasts ( query ) {
return _ _async ( this , null , function * ( ) {
const url = new URL ( "https://itunes.apple.com/search?" ) ;
url . searchParams . append ( "term" , query ) ;
url . searchParams . append ( "media" , "podcast" ) ;
url . searchParams . append ( "limit" , "3" ) ;
url . searchParams . append ( "kind" , "podcast" ) ;
const res = yield ( 0 , import _obsidian2 . requestUrl ) ( { url : url . href } ) ;
const data = res . json . results ;
return data . map ( ( d ) => ( {
title : d . collectionName ,
url : d . feedUrl ,
artworkUrl : d . artworkUrl100 ,
collectionId : d . collectionId
} ) ) ;
} ) ;
}
// src/parser/feedParser.ts
var import _obsidian3 = require ( "obsidian" ) ;
var FeedParser = class {
constructor ( feed ) {
this . feed = feed ;
}
findItemByTitle ( title , url ) {
return _ _async ( this , null , function * ( ) {
const body = yield this . parseFeed ( url ) ;
const items = body . querySelectorAll ( "item" ) ;
const item = Array . from ( items ) . find ( ( item2 ) => {
const parsed = this . parseItem ( item2 ) ;
const isMatch = parsed && parsed . title === title ;
return isMatch ;
} ) ;
if ( ! item ) {
throw new Error ( "Could not find episode" ) ;
}
const episode = this . parseItem ( item ) ;
const feed = yield this . getFeed ( url ) ;
if ( ! episode ) {
throw new Error ( "Episode is invalid." ) ;
}
if ( ! episode . artworkUrl ) {
episode . artworkUrl = feed . artworkUrl ;
}
if ( ! episode . podcastName ) {
episode . podcastName = feed . title ;
}
if ( ! episode . feedUrl ) {
episode . feedUrl = feed . url ;
}
return episode ;
} ) ;
}
getEpisodes ( url ) {
return _ _async ( this , null , function * ( ) {
const body = yield this . parseFeed ( url ) ;
return this . parsePage ( body ) ;
} ) ;
}
getFeed ( url ) {
return _ _async ( this , null , function * ( ) {
var _a ;
const body = yield this . parseFeed ( url ) ;
const titleEl = body . querySelector ( "title" ) ;
const linkEl = body . querySelector ( "link" ) ;
const itunesImageEl = body . querySelector ( "image" ) ;
if ( ! titleEl || ! linkEl ) {
throw new Error ( "Invalid RSS feed" ) ;
}
const title = titleEl . textContent || "" ;
const artworkUrl = ( itunesImageEl == null ? void 0 : itunesImageEl . getAttribute ( "href" ) ) || ( ( _a = itunesImageEl == null ? void 0 : itunesImageEl . querySelector ( "url" ) ) == null ? void 0 : _a . textContent ) || "" ;
return {
title ,
url ,
artworkUrl
} ;
} ) ;
}
parsePage ( page ) {
const items = page . querySelectorAll ( "item" ) ;
function isEpisode ( ep ) {
return ! ! ep ;
}
return Array . from ( items ) . map ( this . parseItem . bind ( this ) ) . filter ( isEpisode ) ;
}
parseItem ( item ) {
var _a , _b , _c , _d ;
const titleEl = item . querySelector ( "title" ) ;
const streamUrlEl = item . querySelector ( "enclosure" ) ;
const linkEl = item . querySelector ( "link" ) ;
const descriptionEl = item . querySelector ( "description" ) ;
const contentEl = item . querySelector ( "*|encoded" ) ;
const pubDateEl = item . querySelector ( "pubDate" ) ;
const itunesImageEl = item . querySelector ( "image" ) ;
const itunesTitleEl = item . getElementsByTagName ( "itunes:title" ) [ 0 ] ;
if ( ! titleEl || ! streamUrlEl || ! pubDateEl ) {
return null ;
}
const title = titleEl . textContent || "" ;
const streamUrl = streamUrlEl . getAttribute ( "url" ) || "" ;
const url = ( linkEl == null ? void 0 : linkEl . textContent ) || "" ;
const description = ( descriptionEl == null ? void 0 : descriptionEl . textContent ) || "" ;
const content = ( contentEl == null ? void 0 : contentEl . textContent ) || "" ;
const pubDate = new Date ( pubDateEl . textContent ) ;
const artworkUrl = ( itunesImageEl == null ? void 0 : itunesImageEl . getAttribute ( "href" ) ) || ( ( _a = this . feed ) == null ? void 0 : _a . artworkUrl ) ;
const itunesTitle = itunesTitleEl == null ? void 0 : itunesTitleEl . textContent ;
return {
title ,
streamUrl ,
url : url || ( ( _b = this . feed ) == null ? void 0 : _b . url ) || "" ,
description ,
content ,
podcastName : ( ( _c = this . feed ) == null ? void 0 : _c . title ) || "" ,
artworkUrl ,
episodeDate : pubDate ,
feedUrl : ( ( _d = this . feed ) == null ? void 0 : _d . url ) || "" ,
itunesTitle : itunesTitle || ""
} ;
}
parseFeed ( feedUrl ) {
return _ _async ( this , null , function * ( ) {
const req = yield ( 0 , import _obsidian3 . requestUrl ) ( { url : feedUrl } ) ;
const dp = new DOMParser ( ) ;
const body = dp . parseFromString ( req . text , "text/xml" ) ;
return body ;
} ) ;
}
} ;
// src/utility/checkStringIsUrl.ts
function checkStringIsUrl ( url ) {
try {
return new URL ( url ) ;
} catch ( e ) {
return null ;
}
}
// src/ui/obsidian/Text.svelte
var import _obsidian4 = require ( "obsidian" ) ;
// src/utility/extractStylesFromObj.ts
function extractStylesFromObj ( obj ) {
return Object . entries ( obj ) . map ( ( [ key , value ] ) => ` ${ key } : ${ value } ` ) . join ( "; " ) ;
}
// src/ui/obsidian/Text.svelte
function create _fragment ( ctx ) {
let span ;
return {
c ( ) {
span = element ( "span" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
ctx [ 6 ] ( span ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
ctx [ 6 ] ( null ) ;
}
} ;
}
function instance ( $$self , $$props , $$invalidate ) {
let { value = "" } = $$props ;
let { disabled = false } = $$props ;
let { placeholder = "" } = $$props ;
let { type = "text" } = $$props ;
let textRef ;
const dispatch = createEventDispatcher ( ) ;
let text2 ;
let { style : styles = { } } = $$props ;
onMount ( ( ) => {
text2 = new import _obsidian4 . TextComponent ( textRef ) ;
updateTextComponentAttributes ( text2 ) ;
} ) ;
afterUpdate ( ( ) => {
updateTextComponentAttributes ( text2 ) ;
} ) ;
function updateTextComponentAttributes ( component ) {
if ( value !== void 0 )
component . setValue ( value ) ;
if ( disabled )
component . setDisabled ( disabled ) ;
if ( placeholder )
component . setPlaceholder ( placeholder ) ;
if ( type )
component . inputEl . type = type ;
if ( styles ) {
text2 . inputEl . setAttr ( "style" , extractStylesFromObj ( styles ) ) ;
}
component . onChange ( ( newValue ) => {
$$invalidate ( 1 , value = newValue ) ;
dispatch ( "change" , { value : newValue } ) ;
} ) ;
}
function span _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
textRef = $$value ;
$$invalidate ( 0 , textRef ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "value" in $$props2 )
$$invalidate ( 1 , value = $$props2 . value ) ;
if ( "disabled" in $$props2 )
$$invalidate ( 2 , disabled = $$props2 . disabled ) ;
if ( "placeholder" in $$props2 )
$$invalidate ( 3 , placeholder = $$props2 . placeholder ) ;
if ( "type" in $$props2 )
$$invalidate ( 4 , type = $$props2 . type ) ;
if ( "style" in $$props2 )
$$invalidate ( 5 , styles = $$props2 . style ) ;
} ;
return [ textRef , value , disabled , placeholder , type , styles , span _binding ] ;
}
var Text = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance , create _fragment , safe _not _equal , {
value : 1 ,
disabled : 2 ,
placeholder : 3 ,
type : 4 ,
style : 5
} ) ;
}
} ;
var Text _default = Text ;
// src/ui/obsidian/Button.svelte
var import _obsidian5 = require ( "obsidian" ) ;
// src/types/IconType.ts
var ICON _LIST _UNIQUE = /* @__PURE__ */ new Set ( [ "activity" , "airplay" , "alarm-check" , "alarm-clock-off" , "alarm-clock" , "alarm-minus" , "alarm-plus" , "album" , "alert-circle" , "alert-octagon" , "alert-triangle" , "align-center-horizontal" , "align-center-vertical" , "align-center" , "align-end-horizontal" , "align-end-vertical" , "align-horizontal-distribute-center" , "align-horizontal-distribute-end" , "align-horizontal-distribute-start" , "align-horizontal-justify-center" , "align-horizontal-justify-end" , "align-horizontal-justify-start" , "align-horizontal-space-around" , "align-horizontal-space-between" , "align-justify" , "align-left" , "align-right" , "align-start-horizontal" , "align-start-vertical" , "align-vertical-distribute-center" , "align-vertical-distribute-end" , "align-vertical-distribute-start" , "align-vertical-justify-center" , "align-vertical-justify-end" , "align-vertical-justify-start" , "align-vertical-space-around" , "align-vertical-space-between" , "anchor" , "aperture" , "archive" , "arrow-big-down" , "arrow-big-left" , "arrow-big-right" , "arrow-big-up" , "arrow-down-circle" , "arrow-down-left" , "arrow-down-right" , "arrow-down" , "arrow-left-circle" , "arrow-left-right" , "arrow-left" , "arrow-right-circle" , "arrow-right" , "arrow-up-circle" , "arrow-up-left" , "arrow-up-right" , "arrow-up" , "asterisk" , "at-sign" , "award" , "axe" , "banknote" , "bar-chart-2" , "bar-chart" , "baseline" , "battery-charging" , "battery-full" , "battery-low" , "battery-medium" , "battery" , "beaker" , "bell-minus" , "bell-off" , "bell-plus" , "bell-ring" , "bell" , "bike" , "binary" , "bitcoin" , "bluetooth-connected" , "bluetooth-off" , "bluetooth-searching" , "bluetooth" , "bold" , "book-open" , "book" , "bookmark-minus" , "bookmark-plus" , "bookmark" , "bot" , "box-select" , "box" , "briefcase" , "brush" , "bug" , "building-2" , "building" , "bus" , "calculator" , "calendar" , "camera-off" , "camera" , "car" , "carrot" , "cast" , "check-circle-2" , "check-circle" , "check-square" , "check" , "chevron-down" , "chevron-first" , "chevron-last" , "chevron-left" , "chevron-right" , "chevron-up" , "chevrons-down-up" , "chevrons-down" , "chevrons-left" , "chevrons-right" , "chevrons-up-down" , "chevrons-up" , "chrome" , "circle-slashed" , "circle" , "clipboard-check" , "clipboard-copy" , "clipboard-list" , "clipboard-x" , "clipboard" , "clock-1" , "clock-10" , "clock-11" , "clock-12" , "clock-2" , "clock-3" , "clock-4" , "clock-5" , "clock-6" , "clock-7" , "clock-8" , "clock-9" , "clock" , "cloud-drizzle" , "cloud-fog" , "cloud-hail" , "cloud-lightning" , "cloud-moon" , "cloud-off" , "cloud-rain-wind" , "cloud-rain" , "cloud-snow" , "cloud-sun" , "cloud" , "cloudy" , "clover" , "code-2" , "code" , "codepen" , "codesandbox" , "coffee" , "coins" , "columns" , "command" , "compass" , "contact" , "contrast" , "cookie" , "copy" , "copyleft" , "copyright" , "corner-down-left" , "corner-down-right" , "corner-left-down" , "corner-left-up" , "corner-right-down" , "corner-right-up" , "corner-up-left" , "corner-up-right" , "cpu" , "credit-card" , "crop" , "cross" , "crosshair" , "crown" , "currency" , "database" , "delete" , "dice-1" , "dice-2" , "dice-3" , "dice-4" , "dice-5" , "dice-6" , "disc" , "divide-circle" , "divide-square" , "divide" , "dollar-sign" , "download-cloud" , "download" , "dribbble" , "droplet" , "droplets" , "drumstick" , "edit-2" , "edit-3" , "edit" , "egg" , "equal-not" , "equal" , "eraser" , "euro" , "expand" , "external-link" , "eye-off" , "eye" , "facebook" , "fast-forward" , "feather" , "figma" , "file-check-2" , "file-check" , "file-code" , "file-digit" , "file-input" , "file-minus-2" , "file-minus" , "file-output" , "file-plus-2" , "file-plus" , "file-search" , "file-text" , "file-x-2" , "file-x" , "file" , "files" , "film" , "filter" , "flag-off" , "flag-triangle-left" , "flag-triangle-right" , "flag" , "flame" , "flashlight-off" , "flashlight" , "flask-conical" , "flask-round" , "folder-minus" , "folder-open" , "folder-plus" , "folder" , "form-input" , "forward" , "frame" , "framer" , "frown" , "function-square" , "gamepad-2" , "gamepad" , "gauge" , "gavel" , "gem" , "ghost" , "gift" , "git-branch-plus" , "git-branch" , "git-commit" , "git-fork" , "git-merge" , "git-pull-request" , "github" , "gitlab" , "glasses" , "globe-2" , "globe" , "grab" , " graduati
var ICON _LIST = Array . from ( ICON _LIST _UNIQUE ) ;
// src/ui/obsidian/Button.svelte
function create _fragment2 ( ctx ) {
let span ;
return {
c ( ) {
span = element ( "span" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
ctx [ 9 ] ( span ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
ctx [ 9 ] ( null ) ;
}
} ;
}
function instance2 ( $$self , $$props , $$invalidate ) {
let { text : text2 = "" } = $$props ;
let { tooltip = "" } = $$props ;
let { icon = void 0 } = $$props ;
let { disabled = false } = $$props ;
let { warning = false } = $$props ;
let { cta = false } = $$props ;
let buttonRef ;
let { class : className } = $$props ;
let { style : styles } = $$props ;
let button ;
const dispatch = createEventDispatcher ( ) ;
onMount ( ( ) => createButton ( buttonRef ) ) ;
afterUpdate ( ( ) => updateButtonAttributes ( button ) ) ;
function createButton ( container ) {
button = new import _obsidian5 . ButtonComponent ( container ) ;
updateButtonAttributes ( button ) ;
}
function updateButtonAttributes ( btn ) {
if ( text2 )
btn . setButtonText ( text2 ) ;
if ( tooltip )
btn . setTooltip ( tooltip ) ;
if ( icon )
btn . setIcon ( icon ) ;
if ( disabled )
btn . setDisabled ( disabled ) ;
if ( warning )
btn . setWarning ( ) ;
else
btn . buttonEl . classList . remove ( "mod-warning" ) ;
if ( className )
btn . setClass ( className ) ;
if ( cta )
btn . setCta ( ) ;
else
btn . removeCta ( ) ;
btn . onClick ( ( event ) => {
dispatch ( "click" , { event } ) ;
} ) ;
if ( styles ) {
btn . buttonEl . setAttr ( "style" , extractStylesFromObj ( styles ) ) ;
}
}
function span _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
buttonRef = $$value ;
$$invalidate ( 0 , buttonRef ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "text" in $$props2 )
$$invalidate ( 1 , text2 = $$props2 . text ) ;
if ( "tooltip" in $$props2 )
$$invalidate ( 2 , tooltip = $$props2 . tooltip ) ;
if ( "icon" in $$props2 )
$$invalidate ( 3 , icon = $$props2 . icon ) ;
if ( "disabled" in $$props2 )
$$invalidate ( 4 , disabled = $$props2 . disabled ) ;
if ( "warning" in $$props2 )
$$invalidate ( 5 , warning = $$props2 . warning ) ;
if ( "cta" in $$props2 )
$$invalidate ( 6 , cta = $$props2 . cta ) ;
if ( "class" in $$props2 )
$$invalidate ( 7 , className = $$props2 . class ) ;
if ( "style" in $$props2 )
$$invalidate ( 8 , styles = $$props2 . style ) ;
} ;
return [
buttonRef ,
text2 ,
tooltip ,
icon ,
disabled ,
warning ,
cta ,
className ,
styles ,
span _binding
] ;
}
var Button = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance2 , create _fragment2 , safe _not _equal , {
text : 1 ,
tooltip : 2 ,
icon : 3 ,
disabled : 4 ,
warning : 5 ,
cta : 6 ,
class : 7 ,
style : 8
} ) ;
}
} ;
var Button _default = Button ;
// src/ui/settings/PodcastResultCard.svelte
function add _css ( target ) {
append _styles ( target , "svelte-19t0wm1" , ".podcast-query-card.svelte-19t0wm1{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%}.podcast-query-image-container.svelte-19t0wm1{width:100%;display:flex;align-items:center;justify-content:center}.podcast-query-heading.svelte-19t0wm1{text-align:center}.podcast-query-button-container.svelte-19t0wm1{margin-top:auto}" ) ;
}
function create _fragment3 ( ctx ) {
let div2 ;
let div0 ;
let img ;
let img _src _value ;
let img _alt _value ;
let t0 ;
let h4 ;
let t1 _value = ctx [ 0 ] . title + "" ;
let t1 ;
let t2 ;
let div1 ;
let button ;
let current ;
button = new Button _default ( {
props : {
text : ctx [ 1 ] ? "Remove" : "Add" ,
warning : ctx [ 1 ] ,
style : { "cursor" : "pointer" }
}
} ) ;
button . $on ( "click" , function ( ) {
if ( is _function ( ctx [ 1 ] ? ctx [ 3 ] : ctx [ 2 ] ) )
( ctx [ 1 ] ? ctx [ 3 ] : ctx [ 2 ] ) . apply ( this , arguments ) ;
} ) ;
return {
c ( ) {
div2 = element ( "div" ) ;
div0 = element ( "div" ) ;
img = element ( "img" ) ;
t0 = space ( ) ;
h4 = element ( "h4" ) ;
t1 = text ( t1 _value ) ;
t2 = space ( ) ;
div1 = element ( "div" ) ;
create _component ( button . $$ . fragment ) ;
set _style ( img , "width" , "100%" ) ;
if ( ! src _url _equal ( img . src , img _src _value = ctx [ 0 ] . artworkUrl ) )
attr ( img , "src" , img _src _value ) ;
attr ( img , "alt" , img _alt _value = ctx [ 0 ] . title ) ;
attr ( div0 , "class" , "podcast-query-image-container svelte-19t0wm1" ) ;
attr ( h4 , "class" , "podcast-query-heading svelte-19t0wm1" ) ;
attr ( div1 , "class" , "podcast-query-button-container svelte-19t0wm1" ) ;
attr ( div2 , "class" , "podcast-query-card svelte-19t0wm1" ) ;
} ,
m ( target , anchor ) {
insert ( target , div2 , anchor ) ;
append ( div2 , div0 ) ;
append ( div0 , img ) ;
append ( div2 , t0 ) ;
append ( div2 , h4 ) ;
append ( h4 , t1 ) ;
append ( div2 , t2 ) ;
append ( div2 , div1 ) ;
mount _component ( button , div1 , null ) ;
current = true ;
} ,
p ( new _ctx , [ dirty ] ) {
ctx = new _ctx ;
if ( ! current || dirty & 1 && ! src _url _equal ( img . src , img _src _value = ctx [ 0 ] . artworkUrl ) ) {
attr ( img , "src" , img _src _value ) ;
}
if ( ! current || dirty & 1 && img _alt _value !== ( img _alt _value = ctx [ 0 ] . title ) ) {
attr ( img , "alt" , img _alt _value ) ;
}
if ( ( ! current || dirty & 1 ) && t1 _value !== ( t1 _value = ctx [ 0 ] . title + "" ) )
set _data ( t1 , t1 _value ) ;
const button _changes = { } ;
if ( dirty & 2 )
button _changes . text = ctx [ 1 ] ? "Remove" : "Add" ;
if ( dirty & 2 )
button _changes . warning = ctx [ 1 ] ;
button . $set ( button _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( button . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( button . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div2 ) ;
destroy _component ( button ) ;
}
} ;
}
function instance3 ( $$self , $$props , $$invalidate ) {
let { podcast } = $$props ;
let { isSaved = false } = $$props ;
const dispatch = createEventDispatcher ( ) ;
function onClickAddPodcast ( ) {
dispatch ( "addPodcast" , { podcast } ) ;
}
function onClickRemovePodcast ( ) {
dispatch ( "removePodcast" , { podcast } ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "podcast" in $$props2 )
$$invalidate ( 0 , podcast = $$props2 . podcast ) ;
if ( "isSaved" in $$props2 )
$$invalidate ( 1 , isSaved = $$props2 . isSaved ) ;
} ;
return [ podcast , isSaved , onClickAddPodcast , onClickRemovePodcast ] ;
}
var PodcastResultCard = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance3 , create _fragment3 , safe _not _equal , { podcast : 0 , isSaved : 1 } , add _css ) ;
}
} ;
var PodcastResultCard _default = PodcastResultCard ;
// src/ui/settings/PodcastQueryGrid.svelte
function add _css2 ( target ) {
append _styles ( target , "svelte-lyr6b4" , ".podcast-query-container.svelte-lyr6b4{margin-bottom:2rem}.podcast-query-results.svelte-lyr6b4{width:100%;height:100%;display:grid;grid-gap:1rem}.grid-3.svelte-lyr6b4{grid-template-columns:repeat(3, 1fr)}.grid-2.svelte-lyr6b4{grid-template-columns:repeat(2, 1fr)}.grid-1.svelte-lyr6b4{grid-template-columns:repeat(1, 1fr)}" ) ;
}
function get _each _context ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 6 ] = list [ i ] ;
return child _ctx ;
}
function create _each _block ( ctx ) {
var _a ;
let podcastresultcard ;
let current ;
podcastresultcard = new PodcastResultCard _default ( {
props : {
podcast : ctx [ 6 ] ,
isSaved : typeof ctx [ 6 ] . url === "string" && ( ( _a = ctx [ 2 ] [ ctx [ 6 ] . title ] ) == null ? void 0 : _a . url ) === ctx [ 6 ] . url
}
} ) ;
podcastresultcard . $on ( "addPodcast" , ctx [ 4 ] ) ;
podcastresultcard . $on ( "removePodcast" , ctx [ 5 ] ) ;
return {
c ( ) {
create _component ( podcastresultcard . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( podcastresultcard , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
var _a2 ;
const podcastresultcard _changes = { } ;
if ( dirty & 1 )
podcastresultcard _changes . podcast = ctx2 [ 6 ] ;
if ( dirty & 5 )
podcastresultcard _changes . isSaved = typeof ctx2 [ 6 ] . url === "string" && ( ( _a2 = ctx2 [ 2 ] [ ctx2 [ 6 ] . title ] ) == null ? void 0 : _a2 . url ) === ctx2 [ 6 ] . url ;
podcastresultcard . $set ( podcastresultcard _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( podcastresultcard . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( podcastresultcard . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( podcastresultcard , detaching ) ;
}
} ;
}
function create _fragment4 ( ctx ) {
let div1 ;
let text _1 ;
let t ;
let div0 ;
let div0 _class _value ;
let current ;
text _1 = new Text _default ( {
props : {
placeholder : "Search..." ,
style : { width : "100%" , "margin-bottom" : "1rem" }
}
} ) ;
text _1 . $on ( "change" , ctx [ 3 ] ) ;
let each _value = ctx [ 0 ] ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
each _blocks [ i ] = create _each _block ( get _each _context ( ctx , each _value , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
return {
c ( ) {
div1 = element ( "div" ) ;
create _component ( text _1 . $$ . fragment ) ;
t = space ( ) ;
div0 = element ( "div" ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
attr ( div0 , "class" , div0 _class _value = null _to _empty ( `
podcast - query - results
$ { ctx [ 1 ] }
` ) + " svelte-lyr6b4");
attr ( div1 , "class" , "podcast-query-container svelte-lyr6b4" ) ;
} ,
m ( target , anchor ) {
insert ( target , div1 , anchor ) ;
mount _component ( text _1 , div1 , null ) ;
append ( div1 , t ) ;
append ( div1 , div0 ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( div0 , null ) ;
}
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
if ( dirty & 53 ) {
each _value = ctx2 [ 0 ] ;
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context ( ctx2 , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( div0 , null ) ;
}
}
group _outros ( ) ;
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
if ( ! current || dirty & 2 && div0 _class _value !== ( div0 _class _value = null _to _empty ( `
podcast - query - results
$ { ctx2 [ 1 ] }
` ) + " svelte-lyr6b4")) {
attr ( div0 , "class" , div0 _class _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( text _1 . $$ . fragment , local ) ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
current = true ;
} ,
o ( local ) {
transition _out ( text _1 . $$ . fragment , local ) ;
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div1 ) ;
destroy _component ( text _1 ) ;
destroy _each ( each _blocks , detaching ) ;
}
} ;
}
function instance4 ( $$self , $$props , $$invalidate ) {
let $savedFeeds ;
component _subscribe ( $$self , savedFeeds , ( $$value ) => $$invalidate ( 2 , $savedFeeds = $$value ) ) ;
let searchResults = [ ] ;
let gridSizeClass = "grid-3" ;
if ( searchResults . length % 3 === 0 || searchResults . length > 3 ) {
gridSizeClass = "grid-3" ;
} else if ( searchResults . length % 2 === 0 ) {
gridSizeClass = "grid-2" ;
} else if ( searchResults . length % 1 === 0 ) {
gridSizeClass = "grid-1" ;
}
const debouncedUpdate = ( 0 , import _obsidian6 . debounce ) ( ( { detail : { value } } ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
const customFeedUrl = checkStringIsUrl ( value ) ;
if ( customFeedUrl ) {
const feed = yield new FeedParser ( ) . getFeed ( customFeedUrl . href ) ;
$$invalidate ( 0 , searchResults = [ feed ] ) ;
return ;
}
$$invalidate ( 0 , searchResults = yield queryiTunesPodcasts ( value ) ) ;
} ) , 300 , true ) ;
function addPodcast ( event ) {
const { podcast } = event . detail ;
savedFeeds . update ( ( feeds ) => Object . assign ( Object . assign ( { } , feeds ) , { [ podcast . title ] : podcast } ) ) ;
}
function removePodcast ( event ) {
const { podcast } = event . detail ;
savedFeeds . update ( ( feeds ) => {
const newFeeds = Object . assign ( { } , feeds ) ;
delete newFeeds [ podcast . title ] ;
return newFeeds ;
} ) ;
}
return [
searchResults ,
gridSizeClass ,
$savedFeeds ,
debouncedUpdate ,
addPodcast ,
removePodcast
] ;
}
var PodcastQueryGrid = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance4 , create _fragment4 , safe _not _equal , { } , add _css2 ) ;
}
} ;
var PodcastQueryGrid _default = PodcastQueryGrid ;
// src/ui/obsidian/Icon.svelte
var import _obsidian7 = require ( "obsidian" ) ;
function add _css3 ( target ) {
append _styles ( target , "svelte-c77uvx" , ".icon-clickable.svelte-c77uvx{cursor:pointer}" ) ;
}
function create _fragment5 ( ctx ) {
let div ;
let span ;
let div _class _value ;
let mounted ;
let dispose ;
return {
c ( ) {
div = element ( "div" ) ;
span = element ( "span" ) ;
attr ( div , "class" , div _class _value = null _to _empty ( ctx [ 0 ] ? "icon-clickable" : "" ) + " svelte-c77uvx" ) ;
attr ( div , "aria-label" , ctx [ 1 ] ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
append ( div , span ) ;
ctx [ 7 ] ( span ) ;
if ( ! mounted ) {
dispose = listen ( div , "click" , ctx [ 3 ] ) ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
if ( dirty & 1 && div _class _value !== ( div _class _value = null _to _empty ( ctx2 [ 0 ] ? "icon-clickable" : "" ) + " svelte-c77uvx" ) ) {
attr ( div , "class" , div _class _value ) ;
}
if ( dirty & 2 ) {
attr ( div , "aria-label" , ctx2 [ 1 ] ) ;
}
} ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
ctx [ 7 ] ( null ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function instance5 ( $$self , $$props , $$invalidate ) {
let { size = 16 } = $$props ;
let { icon } = $$props ;
let { clickable = true } = $$props ;
let { label = "" } = $$props ;
let ref ;
let { style : styles = { } } = $$props ;
let stylesStr ;
const dispatch = createEventDispatcher ( ) ;
onMount ( ( ) => {
( 0 , import _obsidian7 . setIcon ) ( ref , icon , size ) ;
$$invalidate ( 2 , ref . style . cssText = stylesStr , ref ) ;
} ) ;
afterUpdate ( ( ) => {
( 0 , import _obsidian7 . setIcon ) ( ref , icon , size ) ;
$$invalidate ( 2 , ref . style . cssText = stylesStr , ref ) ;
} ) ;
function forwardClick ( event ) {
dispatch ( "click" , { event } ) ;
}
function span _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
ref = $$value ;
$$invalidate ( 2 , ref ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "size" in $$props2 )
$$invalidate ( 4 , size = $$props2 . size ) ;
if ( "icon" in $$props2 )
$$invalidate ( 5 , icon = $$props2 . icon ) ;
if ( "clickable" in $$props2 )
$$invalidate ( 0 , clickable = $$props2 . clickable ) ;
if ( "label" in $$props2 )
$$invalidate ( 1 , label = $$props2 . label ) ;
if ( "style" in $$props2 )
$$invalidate ( 6 , styles = $$props2 . style ) ;
} ;
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty & 64 ) {
$ :
stylesStr = extractStylesFromObj ( styles ) ;
}
} ;
return [ clickable , label , ref , forwardClick , size , icon , styles , span _binding ] ;
}
var Icon = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance5 , create _fragment5 , safe _not _equal , {
size : 4 ,
icon : 5 ,
clickable : 0 ,
label : 1 ,
style : 6
} , add _css3 ) ;
}
} ;
var Icon _default = Icon ;
// src/ui/settings/PlaylistItem.svelte
function add _css4 ( target ) {
append _styles ( target , "svelte-nlujum" , ".playlist-item.svelte-nlujum{display:flex;align-items:center;justify-content:space-between;padding:0.5rem;border-bottom:1px solid var(--background-modifier-border);width:100%}.playlist-item-left.svelte-nlujum{display:flex;align-items:center}.playlist-item-controls.svelte-nlujum{display:flex;align-items:center;gap:0.25rem}" ) ;
}
function create _if _block ( ctx ) {
let icon ;
let current ;
icon = new Icon _default ( {
props : {
icon : ctx [ 2 ] ? "check" : "trash" ,
label : ctx [ 2 ] ? "Confirm deletion" : "Delete playlist" ,
size : 20 ,
style : { color : "red" }
}
} ) ;
icon . $on ( "click" , ctx [ 3 ] ) ;
return {
c ( ) {
create _component ( icon . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( icon , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const icon _changes = { } ;
if ( dirty & 4 )
icon _changes . icon = ctx2 [ 2 ] ? "check" : "trash" ;
if ( dirty & 4 )
icon _changes . label = ctx2 [ 2 ] ? "Confirm deletion" : "Delete playlist" ;
icon . $set ( icon _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( icon , detaching ) ;
}
} ;
}
function create _fragment6 ( ctx ) {
let div2 ;
let div0 ;
let icon ;
let t0 ;
let span ;
let t1 _value = ctx [ 0 ] . name + "" ;
let t1 ;
let t2 ;
let t3 _value = ctx [ 0 ] . episodes . length + "" ;
let t3 ;
let t4 ;
let t5 ;
let div1 ;
let current ;
icon = new Icon _default ( {
props : {
icon : ctx [ 0 ] . icon ,
style : { "margin-right" : "0.2rem" } ,
clickable : false ,
size : 20
}
} ) ;
let if _block = ctx [ 1 ] && create _if _block ( ctx ) ;
return {
c ( ) {
div2 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( icon . $$ . fragment ) ;
t0 = space ( ) ;
span = element ( "span" ) ;
t1 = text ( t1 _value ) ;
t2 = text ( "\n (" ) ;
t3 = text ( t3 _value ) ;
t4 = text ( ")" ) ;
t5 = space ( ) ;
div1 = element ( "div" ) ;
if ( if _block )
if _block . c ( ) ;
set _style ( span , "font-weight" , "500" ) ;
set _style ( span , "margin-right" , "0.2rem" ) ;
attr ( div0 , "class" , "playlist-item-left svelte-nlujum" ) ;
attr ( div1 , "class" , "playlist-item-controls svelte-nlujum" ) ;
attr ( div2 , "class" , "playlist-item svelte-nlujum" ) ;
} ,
m ( target , anchor ) {
insert ( target , div2 , anchor ) ;
append ( div2 , div0 ) ;
mount _component ( icon , div0 , null ) ;
append ( div0 , t0 ) ;
append ( div0 , span ) ;
append ( span , t1 ) ;
append ( div0 , t2 ) ;
append ( div0 , t3 ) ;
append ( div0 , t4 ) ;
append ( div2 , t5 ) ;
append ( div2 , div1 ) ;
if ( if _block )
if _block . m ( div1 , null ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
const icon _changes = { } ;
if ( dirty & 1 )
icon _changes . icon = ctx2 [ 0 ] . icon ;
icon . $set ( icon _changes ) ;
if ( ( ! current || dirty & 1 ) && t1 _value !== ( t1 _value = ctx2 [ 0 ] . name + "" ) )
set _data ( t1 , t1 _value ) ;
if ( ( ! current || dirty & 1 ) && t3 _value !== ( t3 _value = ctx2 [ 0 ] . episodes . length + "" ) )
set _data ( t3 , t3 _value ) ;
if ( ctx2 [ 1 ] ) {
if ( if _block ) {
if _block . p ( ctx2 , dirty ) ;
if ( dirty & 2 ) {
transition _in ( if _block , 1 ) ;
}
} else {
if _block = create _if _block ( ctx2 ) ;
if _block . c ( ) ;
transition _in ( if _block , 1 ) ;
if _block . m ( div1 , null ) ;
}
} else if ( if _block ) {
group _outros ( ) ;
transition _out ( if _block , 1 , 1 , ( ) => {
if _block = null ;
} ) ;
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div2 ) ;
destroy _component ( icon ) ;
if ( if _block )
if _block . d ( ) ;
}
} ;
}
function instance6 ( $$self , $$props , $$invalidate ) {
let { playlist } = $$props ;
let { showDeleteButton = true } = $$props ;
let clickedDelete = false ;
const dispatch = createEventDispatcher ( ) ;
function onClickedDelete ( event ) {
if ( clickedDelete ) {
dispatch ( "delete" , { value : playlist } ) ;
return ;
}
$$invalidate ( 2 , clickedDelete = true ) ;
setTimeout ( ( ) => {
$$invalidate ( 2 , clickedDelete = false ) ;
} , 2e3 ) ;
}
function onClickedRepeat ( event ) {
dispatch ( "toggleRepeat" , { value : playlist } ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "playlist" in $$props2 )
$$invalidate ( 0 , playlist = $$props2 . playlist ) ;
if ( "showDeleteButton" in $$props2 )
$$invalidate ( 1 , showDeleteButton = $$props2 . showDeleteButton ) ;
} ;
return [ playlist , showDeleteButton , clickedDelete , onClickedDelete ] ;
}
var PlaylistItem = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance6 , create _fragment6 , safe _not _equal , { playlist : 0 , showDeleteButton : 1 } , add _css4 ) ;
}
} ;
var PlaylistItem _default = PlaylistItem ;
// src/ui/obsidian/Dropdown.svelte
var import _obsidian8 = require ( "obsidian" ) ;
function create _fragment7 ( ctx ) {
let span ;
return {
c ( ) {
span = element ( "span" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
ctx [ 5 ] ( span ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
ctx [ 5 ] ( null ) ;
}
} ;
}
function instance7 ( $$self , $$props , $$invalidate ) {
let { value = "" } = $$props ;
let { options = { } } = $$props ;
let { disabled = false } = $$props ;
let dropdownRef ;
let dropdown ;
let { style : styles } = $$props ;
const dispatch = createEventDispatcher ( ) ;
onMount ( ( ) => {
dropdown = new import _obsidian8 . DropdownComponent ( dropdownRef ) ;
updateDropdownAttributes ( dropdown ) ;
} ) ;
function updateDropdownAttributes ( dropdown2 ) {
if ( options )
dropdown2 . addOptions ( options ) ;
if ( value )
dropdown2 . setValue ( value ) ;
if ( disabled )
dropdown2 . setDisabled ( disabled ) ;
dropdown2 . onChange ( ( value2 ) => {
dispatch ( "change" , { value : value2 } ) ;
} ) ;
if ( styles ) {
dropdown2 . selectEl . setAttr ( "style" , extractStylesFromObj ( styles ) ) ;
}
}
function span _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
dropdownRef = $$value ;
$$invalidate ( 0 , dropdownRef ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "value" in $$props2 )
$$invalidate ( 1 , value = $$props2 . value ) ;
if ( "options" in $$props2 )
$$invalidate ( 2 , options = $$props2 . options ) ;
if ( "disabled" in $$props2 )
$$invalidate ( 3 , disabled = $$props2 . disabled ) ;
if ( "style" in $$props2 )
$$invalidate ( 4 , styles = $$props2 . style ) ;
} ;
return [ dropdownRef , value , options , disabled , styles , span _binding ] ;
}
var Dropdown = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance7 , create _fragment7 , safe _not _equal , {
value : 1 ,
options : 2 ,
disabled : 3 ,
style : 4
} ) ;
}
} ;
var Dropdown _default = Dropdown ;
// src/ui/settings/PlaylistManager.svelte
function add _css5 ( target ) {
append _styles ( target , "svelte-46vu4x" , ".playlist-manager-container.svelte-46vu4x{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;margin-bottom:2rem}.playlist-list.svelte-46vu4x{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;overflow-y:auto}.add-playlist-container.svelte-46vu4x{margin-top:1rem}" ) ;
}
function get _each _context2 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 12 ] = list [ i ] ;
return child _ctx ;
}
function create _each _block2 ( ctx ) {
let playlistitem ;
let current ;
playlistitem = new PlaylistItem _default ( {
props : { playlist : ctx [ 12 ] }
} ) ;
playlistitem . $on ( "delete" , ctx [ 8 ] ) ;
playlistitem . $on ( "toggleRepeat" , ctx [ 9 ] ) ;
return {
c ( ) {
create _component ( playlistitem . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( playlistitem , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const playlistitem _changes = { } ;
if ( dirty & 1 )
playlistitem _changes . playlist = ctx2 [ 12 ] ;
playlistitem . $set ( playlistitem _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( playlistitem . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( playlistitem . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( playlistitem , detaching ) ;
}
} ;
}
function create _fragment8 ( ctx ) {
let div2 ;
let div0 ;
let playlistitem0 ;
let t0 ;
let playlistitem1 ;
let t1 ;
let t2 ;
let div1 ;
let dropdown ;
let updating _value ;
let t3 ;
let text _1 ;
let updating _value _1 ;
let t4 ;
let button ;
let current ;
playlistitem0 = new PlaylistItem _default ( {
props : {
playlist : ctx [ 3 ] ,
showDeleteButton : false
}
} ) ;
playlistitem1 = new PlaylistItem _default ( {
props : {
playlist : ctx [ 4 ] ,
showDeleteButton : false
}
} ) ;
let each _value = ctx [ 0 ] ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
each _blocks [ i ] = create _each _block2 ( get _each _context2 ( ctx , each _value , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
function dropdown _value _binding ( value ) {
ctx [ 10 ] ( value ) ;
}
let dropdown _props = { options : ctx [ 5 ] } ;
if ( ctx [ 2 ] !== void 0 ) {
dropdown _props . value = ctx [ 2 ] ;
}
dropdown = new Dropdown _default ( { props : dropdown _props } ) ;
binding _callbacks . push ( ( ) => bind ( dropdown , "value" , dropdown _value _binding ) ) ;
dropdown . $on ( "change" , ctx [ 7 ] ) ;
function text _1 _value _binding ( value ) {
ctx [ 11 ] ( value ) ;
}
let text _1 _props = { placeholder : "Playlist name" } ;
if ( ctx [ 1 ] !== void 0 ) {
text _1 _props . value = ctx [ 1 ] ;
}
text _1 = new Text _default ( { props : text _1 _props } ) ;
binding _callbacks . push ( ( ) => bind ( text _1 , "value" , text _1 _value _binding ) ) ;
button = new Button _default ( { props : { icon : "plus" , cta : true } } ) ;
button . $on ( "click" , ctx [ 6 ] ) ;
return {
c ( ) {
div2 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( playlistitem0 . $$ . fragment ) ;
t0 = space ( ) ;
create _component ( playlistitem1 . $$ . fragment ) ;
t1 = space ( ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
t2 = space ( ) ;
div1 = element ( "div" ) ;
create _component ( dropdown . $$ . fragment ) ;
t3 = space ( ) ;
create _component ( text _1 . $$ . fragment ) ;
t4 = space ( ) ;
create _component ( button . $$ . fragment ) ;
attr ( div0 , "class" , "playlist-list svelte-46vu4x" ) ;
attr ( div1 , "class" , "add-playlist-container svelte-46vu4x" ) ;
attr ( div2 , "class" , "playlist-manager-container svelte-46vu4x" ) ;
} ,
m ( target , anchor ) {
insert ( target , div2 , anchor ) ;
append ( div2 , div0 ) ;
mount _component ( playlistitem0 , div0 , null ) ;
append ( div0 , t0 ) ;
mount _component ( playlistitem1 , div0 , null ) ;
append ( div0 , t1 ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( div0 , null ) ;
}
append ( div2 , t2 ) ;
append ( div2 , div1 ) ;
mount _component ( dropdown , div1 , null ) ;
append ( div1 , t3 ) ;
mount _component ( text _1 , div1 , null ) ;
append ( div1 , t4 ) ;
mount _component ( button , div1 , null ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
const playlistitem0 _changes = { } ;
if ( dirty & 8 )
playlistitem0 _changes . playlist = ctx2 [ 3 ] ;
playlistitem0 . $set ( playlistitem0 _changes ) ;
const playlistitem1 _changes = { } ;
if ( dirty & 16 )
playlistitem1 _changes . playlist = ctx2 [ 4 ] ;
playlistitem1 . $set ( playlistitem1 _changes ) ;
if ( dirty & 769 ) {
each _value = ctx2 [ 0 ] ;
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context2 ( ctx2 , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block2 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( div0 , null ) ;
}
}
group _outros ( ) ;
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
const dropdown _changes = { } ;
if ( ! updating _value && dirty & 4 ) {
updating _value = true ;
dropdown _changes . value = ctx2 [ 2 ] ;
add _flush _callback ( ( ) => updating _value = false ) ;
}
dropdown . $set ( dropdown _changes ) ;
const text _1 _changes = { } ;
if ( ! updating _value _1 && dirty & 2 ) {
updating _value _1 = true ;
text _1 _changes . value = ctx2 [ 1 ] ;
add _flush _callback ( ( ) => updating _value _1 = false ) ;
}
text _1 . $set ( text _1 _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( playlistitem0 . $$ . fragment , local ) ;
transition _in ( playlistitem1 . $$ . fragment , local ) ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
transition _in ( dropdown . $$ . fragment , local ) ;
transition _in ( text _1 . $$ . fragment , local ) ;
transition _in ( button . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( playlistitem0 . $$ . fragment , local ) ;
transition _out ( playlistitem1 . $$ . fragment , local ) ;
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
transition _out ( dropdown . $$ . fragment , local ) ;
transition _out ( text _1 . $$ . fragment , local ) ;
transition _out ( button . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div2 ) ;
destroy _component ( playlistitem0 ) ;
destroy _component ( playlistitem1 ) ;
destroy _each ( each _blocks , detaching ) ;
destroy _component ( dropdown ) ;
destroy _component ( text _1 ) ;
destroy _component ( button ) ;
}
} ;
}
function instance8 ( $$self , $$props , $$invalidate ) {
let $queue ;
let $favorites ;
component _subscribe ( $$self , queue , ( $$value ) => $$invalidate ( 3 , $queue = $$value ) ) ;
component _subscribe ( $$self , favorites , ( $$value ) => $$invalidate ( 4 , $favorites = $$value ) ) ;
let playlistArr = [ ] ;
let playlistInput = "" ;
let options = ICON _LIST . reduce ( ( acc , curr ) => {
acc [ curr ] = curr ;
return acc ;
} , { } ) ;
let icon = ICON _LIST [ 0 ] ;
onMount ( ( ) => {
const unsubscribe = playlists . subscribe ( ( playlists2 ) => {
$$invalidate ( 0 , playlistArr = Object . values ( playlists2 ) ) ;
} ) ;
return ( ) => {
unsubscribe ( ) ;
} ;
} ) ;
function onAddPlaylist ( ) {
playlists . update ( ( value ) => {
value [ playlistInput ] = {
name : playlistInput ,
icon ,
episodes : [ ] ,
shouldEpisodeRemoveAfterPlay : false ,
shouldRepeat : false
} ;
return value ;
} ) ;
$$invalidate ( 1 , playlistInput = "" ) ;
$$invalidate ( 2 , icon = ICON _LIST [ 0 ] ) ;
}
function onChangeIcon ( event ) {
$$invalidate ( 2 , icon = event . detail . value ) ;
}
function onDeletePlaylist ( event ) {
playlists . update ( ( value ) => {
delete value [ event . detail . value . name ] ;
return value ;
} ) ;
}
function onToggleRepeat ( event ) {
playlists . update ( ( value ) => {
value [ event . detail . value . name ] . shouldRepeat = ! value [ event . detail . value . name ] . shouldRepeat ;
return value ;
} ) ;
}
function dropdown _value _binding ( value ) {
icon = value ;
$$invalidate ( 2 , icon ) ;
}
function text _1 _value _binding ( value ) {
playlistInput = value ;
$$invalidate ( 1 , playlistInput ) ;
}
return [
playlistArr ,
playlistInput ,
icon ,
$queue ,
$favorites ,
options ,
onAddPlaylist ,
onChangeIcon ,
onDeletePlaylist ,
onToggleRepeat ,
dropdown _value _binding ,
text _1 _value _binding
] ;
}
var PlaylistManager = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance8 , create _fragment8 , safe _not _equal , { } , add _css5 ) ;
}
} ;
var PlaylistManager _default = PlaylistManager ;
// src/TemplateEngine.ts
var import _obsidian9 = require ( "obsidian" ) ;
// node_modules/fuse.js/dist/fuse.esm.js
function isArray ( value ) {
return ! Array . isArray ? getTag ( value ) === "[object Array]" : Array . isArray ( value ) ;
}
var INFINITY = 1 / 0 ;
function baseToString ( value ) {
if ( typeof value == "string" ) {
return value ;
}
let result = value + "" ;
return result == "0" && 1 / value == - INFINITY ? "-0" : result ;
}
function toString ( value ) {
return value == null ? "" : baseToString ( value ) ;
}
function isString ( value ) {
return typeof value === "string" ;
}
function isNumber ( value ) {
return typeof value === "number" ;
}
function isBoolean ( value ) {
return value === true || value === false || isObjectLike ( value ) && getTag ( value ) == "[object Boolean]" ;
}
function isObject ( value ) {
return typeof value === "object" ;
}
function isObjectLike ( value ) {
return isObject ( value ) && value !== null ;
}
function isDefined ( value ) {
return value !== void 0 && value !== null ;
}
function isBlank ( value ) {
return ! value . trim ( ) . length ;
}
function getTag ( value ) {
return value == null ? value === void 0 ? "[object Undefined]" : "[object Null]" : Object . prototype . toString . call ( value ) ;
}
var INCORRECT _INDEX _TYPE = "Incorrect 'index' type" ;
var LOGICAL _SEARCH _INVALID _QUERY _FOR _KEY = ( key ) => ` Invalid value for key ${ key } ` ;
var PATTERN _LENGTH _TOO _LARGE = ( max ) => ` Pattern length exceeds max of ${ max } . ` ;
var MISSING _KEY _PROPERTY = ( name ) => ` Missing ${ name } property in key ` ;
var INVALID _KEY _WEIGHT _VALUE = ( key ) => ` Property 'weight' in key ' ${ key } ' must be a positive integer ` ;
var hasOwn = Object . prototype . hasOwnProperty ;
var KeyStore = class {
constructor ( keys ) {
this . _keys = [ ] ;
this . _keyMap = { } ;
let totalWeight = 0 ;
keys . forEach ( ( key ) => {
let obj = createKey ( key ) ;
totalWeight += obj . weight ;
this . _keys . push ( obj ) ;
this . _keyMap [ obj . id ] = obj ;
totalWeight += obj . weight ;
} ) ;
this . _keys . forEach ( ( key ) => {
key . weight /= totalWeight ;
} ) ;
}
get ( keyId ) {
return this . _keyMap [ keyId ] ;
}
keys ( ) {
return this . _keys ;
}
toJSON ( ) {
return JSON . stringify ( this . _keys ) ;
}
} ;
function createKey ( key ) {
let path = null ;
let id = null ;
let src = null ;
let weight = 1 ;
let getFn = null ;
if ( isString ( key ) || isArray ( key ) ) {
src = key ;
path = createKeyPath ( key ) ;
id = createKeyId ( key ) ;
} else {
if ( ! hasOwn . call ( key , "name" ) ) {
throw new Error ( MISSING _KEY _PROPERTY ( "name" ) ) ;
}
const name = key . name ;
src = name ;
if ( hasOwn . call ( key , "weight" ) ) {
weight = key . weight ;
if ( weight <= 0 ) {
throw new Error ( INVALID _KEY _WEIGHT _VALUE ( name ) ) ;
}
}
path = createKeyPath ( name ) ;
id = createKeyId ( name ) ;
getFn = key . getFn ;
}
return { path , id , weight , src , getFn } ;
}
function createKeyPath ( key ) {
return isArray ( key ) ? key : key . split ( "." ) ;
}
function createKeyId ( key ) {
return isArray ( key ) ? key . join ( "." ) : key ;
}
function get ( obj , path ) {
let list = [ ] ;
let arr = false ;
const deepGet = ( obj2 , path2 , index ) => {
if ( ! isDefined ( obj2 ) ) {
return ;
}
if ( ! path2 [ index ] ) {
list . push ( obj2 ) ;
} else {
let key = path2 [ index ] ;
const value = obj2 [ key ] ;
if ( ! isDefined ( value ) ) {
return ;
}
if ( index === path2 . length - 1 && ( isString ( value ) || isNumber ( value ) || isBoolean ( value ) ) ) {
list . push ( toString ( value ) ) ;
} else if ( isArray ( value ) ) {
arr = true ;
for ( let i = 0 , len = value . length ; i < len ; i += 1 ) {
deepGet ( value [ i ] , path2 , index + 1 ) ;
}
} else if ( path2 . length ) {
deepGet ( value , path2 , index + 1 ) ;
}
}
} ;
deepGet ( obj , isString ( path ) ? path . split ( "." ) : path , 0 ) ;
return arr ? list : list [ 0 ] ;
}
var MatchOptions = {
includeMatches : false ,
findAllMatches : false ,
minMatchCharLength : 1
} ;
var BasicOptions = {
isCaseSensitive : false ,
includeScore : false ,
keys : [ ] ,
shouldSort : true ,
sortFn : ( a , b ) => a . score === b . score ? a . idx < b . idx ? - 1 : 1 : a . score < b . score ? - 1 : 1
} ;
var FuzzyOptions = {
location : 0 ,
threshold : 0.6 ,
distance : 100
} ;
var AdvancedOptions = {
useExtendedSearch : false ,
getFn : get ,
ignoreLocation : false ,
ignoreFieldNorm : false ,
fieldNormWeight : 1
} ;
var Config = _ _spreadValues ( _ _spreadValues ( _ _spreadValues ( _ _spreadValues ( { } , BasicOptions ) , MatchOptions ) , FuzzyOptions ) , AdvancedOptions ) ;
var SPACE = /[^ ]+/g ;
function norm ( weight = 1 , mantissa = 3 ) {
const cache = /* @__PURE__ */ new Map ( ) ;
const m = Math . pow ( 10 , mantissa ) ;
return {
get ( value ) {
const numTokens = value . match ( SPACE ) . length ;
if ( cache . has ( numTokens ) ) {
return cache . get ( numTokens ) ;
}
const norm2 = 1 / Math . pow ( numTokens , 0.5 * weight ) ;
const n = parseFloat ( Math . round ( norm2 * m ) / m ) ;
cache . set ( numTokens , n ) ;
return n ;
} ,
clear ( ) {
cache . clear ( ) ;
}
} ;
}
var FuseIndex = class {
constructor ( {
getFn = Config . getFn ,
fieldNormWeight = Config . fieldNormWeight
} = { } ) {
this . norm = norm ( fieldNormWeight , 3 ) ;
this . getFn = getFn ;
this . isCreated = false ;
this . setIndexRecords ( ) ;
}
setSources ( docs = [ ] ) {
this . docs = docs ;
}
setIndexRecords ( records = [ ] ) {
this . records = records ;
}
setKeys ( keys = [ ] ) {
this . keys = keys ;
this . _keysMap = { } ;
keys . forEach ( ( key , idx ) => {
this . _keysMap [ key . id ] = idx ;
} ) ;
}
create ( ) {
if ( this . isCreated || ! this . docs . length ) {
return ;
}
this . isCreated = true ;
if ( isString ( this . docs [ 0 ] ) ) {
this . docs . forEach ( ( doc , docIndex ) => {
this . _addString ( doc , docIndex ) ;
} ) ;
} else {
this . docs . forEach ( ( doc , docIndex ) => {
this . _addObject ( doc , docIndex ) ;
} ) ;
}
this . norm . clear ( ) ;
}
add ( doc ) {
const idx = this . size ( ) ;
if ( isString ( doc ) ) {
this . _addString ( doc , idx ) ;
} else {
this . _addObject ( doc , idx ) ;
}
}
removeAt ( idx ) {
this . records . splice ( idx , 1 ) ;
for ( let i = idx , len = this . size ( ) ; i < len ; i += 1 ) {
this . records [ i ] . i -= 1 ;
}
}
getValueForItemAtKeyId ( item , keyId ) {
return item [ this . _keysMap [ keyId ] ] ;
}
size ( ) {
return this . records . length ;
}
_addString ( doc , docIndex ) {
if ( ! isDefined ( doc ) || isBlank ( doc ) ) {
return ;
}
let record = {
v : doc ,
i : docIndex ,
n : this . norm . get ( doc )
} ;
this . records . push ( record ) ;
}
_addObject ( doc , docIndex ) {
let record = { i : docIndex , $ : { } } ;
this . keys . forEach ( ( key , keyIndex ) => {
let value = key . getFn ? key . getFn ( doc ) : this . getFn ( doc , key . path ) ;
if ( ! isDefined ( value ) ) {
return ;
}
if ( isArray ( value ) ) {
let subRecords = [ ] ;
const stack = [ { nestedArrIndex : - 1 , value } ] ;
while ( stack . length ) {
const { nestedArrIndex , value : value2 } = stack . pop ( ) ;
if ( ! isDefined ( value2 ) ) {
continue ;
}
if ( isString ( value2 ) && ! isBlank ( value2 ) ) {
let subRecord = {
v : value2 ,
i : nestedArrIndex ,
n : this . norm . get ( value2 )
} ;
subRecords . push ( subRecord ) ;
} else if ( isArray ( value2 ) ) {
value2 . forEach ( ( item , k ) => {
stack . push ( {
nestedArrIndex : k ,
value : item
} ) ;
} ) ;
} else
;
}
record . $ [ keyIndex ] = subRecords ;
} else if ( isString ( value ) && ! isBlank ( value ) ) {
let subRecord = {
v : value ,
n : this . norm . get ( value )
} ;
record . $ [ keyIndex ] = subRecord ;
}
} ) ;
this . records . push ( record ) ;
}
toJSON ( ) {
return {
keys : this . keys ,
records : this . records
} ;
}
} ;
function createIndex ( keys , docs , { getFn = Config . getFn , fieldNormWeight = Config . fieldNormWeight } = { } ) {
const myIndex = new FuseIndex ( { getFn , fieldNormWeight } ) ;
myIndex . setKeys ( keys . map ( createKey ) ) ;
myIndex . setSources ( docs ) ;
myIndex . create ( ) ;
return myIndex ;
}
function parseIndex ( data , { getFn = Config . getFn , fieldNormWeight = Config . fieldNormWeight } = { } ) {
const { keys , records } = data ;
const myIndex = new FuseIndex ( { getFn , fieldNormWeight } ) ;
myIndex . setKeys ( keys ) ;
myIndex . setIndexRecords ( records ) ;
return myIndex ;
}
function computeScore$1 ( pattern , {
errors = 0 ,
currentLocation = 0 ,
expectedLocation = 0 ,
distance = Config . distance ,
ignoreLocation = Config . ignoreLocation
} = { } ) {
const accuracy = errors / pattern . length ;
if ( ignoreLocation ) {
return accuracy ;
}
const proximity = Math . abs ( expectedLocation - currentLocation ) ;
if ( ! distance ) {
return proximity ? 1 : accuracy ;
}
return accuracy + proximity / distance ;
}
function convertMaskToIndices ( matchmask = [ ] , minMatchCharLength = Config . minMatchCharLength ) {
let indices = [ ] ;
let start = - 1 ;
let end = - 1 ;
let i = 0 ;
for ( let len = matchmask . length ; i < len ; i += 1 ) {
let match = matchmask [ i ] ;
if ( match && start === - 1 ) {
start = i ;
} else if ( ! match && start !== - 1 ) {
end = i - 1 ;
if ( end - start + 1 >= minMatchCharLength ) {
indices . push ( [ start , end ] ) ;
}
start = - 1 ;
}
}
if ( matchmask [ i - 1 ] && i - start >= minMatchCharLength ) {
indices . push ( [ start , i - 1 ] ) ;
}
return indices ;
}
var MAX _BITS = 32 ;
function search ( text2 , pattern , patternAlphabet , {
location = Config . location ,
distance = Config . distance ,
threshold = Config . threshold ,
findAllMatches = Config . findAllMatches ,
minMatchCharLength = Config . minMatchCharLength ,
includeMatches = Config . includeMatches ,
ignoreLocation = Config . ignoreLocation
} = { } ) {
if ( pattern . length > MAX _BITS ) {
throw new Error ( PATTERN _LENGTH _TOO _LARGE ( MAX _BITS ) ) ;
}
const patternLen = pattern . length ;
const textLen = text2 . length ;
const expectedLocation = Math . max ( 0 , Math . min ( location , textLen ) ) ;
let currentThreshold = threshold ;
let bestLocation = expectedLocation ;
const computeMatches = minMatchCharLength > 1 || includeMatches ;
const matchMask = computeMatches ? Array ( textLen ) : [ ] ;
let index ;
while ( ( index = text2 . indexOf ( pattern , bestLocation ) ) > - 1 ) {
let score = computeScore$1 ( pattern , {
currentLocation : index ,
expectedLocation ,
distance ,
ignoreLocation
} ) ;
currentThreshold = Math . min ( score , currentThreshold ) ;
bestLocation = index + patternLen ;
if ( computeMatches ) {
let i = 0 ;
while ( i < patternLen ) {
matchMask [ index + i ] = 1 ;
i += 1 ;
}
}
}
bestLocation = - 1 ;
let lastBitArr = [ ] ;
let finalScore = 1 ;
let binMax = patternLen + textLen ;
const mask = 1 << patternLen - 1 ;
for ( let i = 0 ; i < patternLen ; i += 1 ) {
let binMin = 0 ;
let binMid = binMax ;
while ( binMin < binMid ) {
const score2 = computeScore$1 ( pattern , {
errors : i ,
currentLocation : expectedLocation + binMid ,
expectedLocation ,
distance ,
ignoreLocation
} ) ;
if ( score2 <= currentThreshold ) {
binMin = binMid ;
} else {
binMax = binMid ;
}
binMid = Math . floor ( ( binMax - binMin ) / 2 + binMin ) ;
}
binMax = binMid ;
let start = Math . max ( 1 , expectedLocation - binMid + 1 ) ;
let finish = findAllMatches ? textLen : Math . min ( expectedLocation + binMid , textLen ) + patternLen ;
let bitArr = Array ( finish + 2 ) ;
bitArr [ finish + 1 ] = ( 1 << i ) - 1 ;
for ( let j = finish ; j >= start ; j -= 1 ) {
let currentLocation = j - 1 ;
let charMatch = patternAlphabet [ text2 . charAt ( currentLocation ) ] ;
if ( computeMatches ) {
matchMask [ currentLocation ] = + ! ! charMatch ;
}
bitArr [ j ] = ( bitArr [ j + 1 ] << 1 | 1 ) & charMatch ;
if ( i ) {
bitArr [ j ] |= ( lastBitArr [ j + 1 ] | lastBitArr [ j ] ) << 1 | 1 | lastBitArr [ j + 1 ] ;
}
if ( bitArr [ j ] & mask ) {
finalScore = computeScore$1 ( pattern , {
errors : i ,
currentLocation ,
expectedLocation ,
distance ,
ignoreLocation
} ) ;
if ( finalScore <= currentThreshold ) {
currentThreshold = finalScore ;
bestLocation = currentLocation ;
if ( bestLocation <= expectedLocation ) {
break ;
}
start = Math . max ( 1 , 2 * expectedLocation - bestLocation ) ;
}
}
}
const score = computeScore$1 ( pattern , {
errors : i + 1 ,
currentLocation : expectedLocation ,
expectedLocation ,
distance ,
ignoreLocation
} ) ;
if ( score > currentThreshold ) {
break ;
}
lastBitArr = bitArr ;
}
const result = {
isMatch : bestLocation >= 0 ,
score : Math . max ( 1e-3 , finalScore )
} ;
if ( computeMatches ) {
const indices = convertMaskToIndices ( matchMask , minMatchCharLength ) ;
if ( ! indices . length ) {
result . isMatch = false ;
} else if ( includeMatches ) {
result . indices = indices ;
}
}
return result ;
}
function createPatternAlphabet ( pattern ) {
let mask = { } ;
for ( let i = 0 , len = pattern . length ; i < len ; i += 1 ) {
const char = pattern . charAt ( i ) ;
mask [ char ] = ( mask [ char ] || 0 ) | 1 << len - i - 1 ;
}
return mask ;
}
var BitapSearch = class {
constructor ( pattern , {
location = Config . location ,
threshold = Config . threshold ,
distance = Config . distance ,
includeMatches = Config . includeMatches ,
findAllMatches = Config . findAllMatches ,
minMatchCharLength = Config . minMatchCharLength ,
isCaseSensitive = Config . isCaseSensitive ,
ignoreLocation = Config . ignoreLocation
} = { } ) {
this . options = {
location ,
threshold ,
distance ,
includeMatches ,
findAllMatches ,
minMatchCharLength ,
isCaseSensitive ,
ignoreLocation
} ;
this . pattern = isCaseSensitive ? pattern : pattern . toLowerCase ( ) ;
this . chunks = [ ] ;
if ( ! this . pattern . length ) {
return ;
}
const addChunk = ( pattern2 , startIndex ) => {
this . chunks . push ( {
pattern : pattern2 ,
alphabet : createPatternAlphabet ( pattern2 ) ,
startIndex
} ) ;
} ;
const len = this . pattern . length ;
if ( len > MAX _BITS ) {
let i = 0 ;
const remainder = len % MAX _BITS ;
const end = len - remainder ;
while ( i < end ) {
addChunk ( this . pattern . substr ( i , MAX _BITS ) , i ) ;
i += MAX _BITS ;
}
if ( remainder ) {
const startIndex = len - MAX _BITS ;
addChunk ( this . pattern . substr ( startIndex ) , startIndex ) ;
}
} else {
addChunk ( this . pattern , 0 ) ;
}
}
searchIn ( text2 ) {
const { isCaseSensitive , includeMatches } = this . options ;
if ( ! isCaseSensitive ) {
text2 = text2 . toLowerCase ( ) ;
}
if ( this . pattern === text2 ) {
let result2 = {
isMatch : true ,
score : 0
} ;
if ( includeMatches ) {
result2 . indices = [ [ 0 , text2 . length - 1 ] ] ;
}
return result2 ;
}
const {
location ,
distance ,
threshold ,
findAllMatches ,
minMatchCharLength ,
ignoreLocation
} = this . options ;
let allIndices = [ ] ;
let totalScore = 0 ;
let hasMatches = false ;
this . chunks . forEach ( ( { pattern , alphabet , startIndex } ) => {
const { isMatch , score , indices } = search ( text2 , pattern , alphabet , {
location : location + startIndex ,
distance ,
threshold ,
findAllMatches ,
minMatchCharLength ,
includeMatches ,
ignoreLocation
} ) ;
if ( isMatch ) {
hasMatches = true ;
}
totalScore += score ;
if ( isMatch && indices ) {
allIndices = [ ... allIndices , ... indices ] ;
}
} ) ;
let result = {
isMatch : hasMatches ,
score : hasMatches ? totalScore / this . chunks . length : 1
} ;
if ( hasMatches && includeMatches ) {
result . indices = allIndices ;
}
return result ;
}
} ;
var BaseMatch = class {
constructor ( pattern ) {
this . pattern = pattern ;
}
static isMultiMatch ( pattern ) {
return getMatch ( pattern , this . multiRegex ) ;
}
static isSingleMatch ( pattern ) {
return getMatch ( pattern , this . singleRegex ) ;
}
search ( ) {
}
} ;
function getMatch ( pattern , exp ) {
const matches = pattern . match ( exp ) ;
return matches ? matches [ 1 ] : null ;
}
var ExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "exact" ;
}
static get multiRegex ( ) {
return /^="(.*)"$/ ;
}
static get singleRegex ( ) {
return /^=(.*)$/ ;
}
search ( text2 ) {
const isMatch = text2 === this . pattern ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ 0 , this . pattern . length - 1 ]
} ;
}
} ;
var InverseExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "inverse-exact" ;
}
static get multiRegex ( ) {
return /^!"(.*)"$/ ;
}
static get singleRegex ( ) {
return /^!(.*)$/ ;
}
search ( text2 ) {
const index = text2 . indexOf ( this . pattern ) ;
const isMatch = index === - 1 ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ 0 , text2 . length - 1 ]
} ;
}
} ;
var PrefixExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "prefix-exact" ;
}
static get multiRegex ( ) {
return /^\^"(.*)"$/ ;
}
static get singleRegex ( ) {
return /^\^(.*)$/ ;
}
search ( text2 ) {
const isMatch = text2 . startsWith ( this . pattern ) ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ 0 , this . pattern . length - 1 ]
} ;
}
} ;
var InversePrefixExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "inverse-prefix-exact" ;
}
static get multiRegex ( ) {
return /^!\^"(.*)"$/ ;
}
static get singleRegex ( ) {
return /^!\^(.*)$/ ;
}
search ( text2 ) {
const isMatch = ! text2 . startsWith ( this . pattern ) ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ 0 , text2 . length - 1 ]
} ;
}
} ;
var SuffixExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "suffix-exact" ;
}
static get multiRegex ( ) {
return /^"(.*)"\$$/ ;
}
static get singleRegex ( ) {
return /^(.*)\$$/ ;
}
search ( text2 ) {
const isMatch = text2 . endsWith ( this . pattern ) ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ text2 . length - this . pattern . length , text2 . length - 1 ]
} ;
}
} ;
var InverseSuffixExactMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "inverse-suffix-exact" ;
}
static get multiRegex ( ) {
return /^!"(.*)"\$$/ ;
}
static get singleRegex ( ) {
return /^!(.*)\$$/ ;
}
search ( text2 ) {
const isMatch = ! text2 . endsWith ( this . pattern ) ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices : [ 0 , text2 . length - 1 ]
} ;
}
} ;
var FuzzyMatch = class extends BaseMatch {
constructor ( pattern , {
location = Config . location ,
threshold = Config . threshold ,
distance = Config . distance ,
includeMatches = Config . includeMatches ,
findAllMatches = Config . findAllMatches ,
minMatchCharLength = Config . minMatchCharLength ,
isCaseSensitive = Config . isCaseSensitive ,
ignoreLocation = Config . ignoreLocation
} = { } ) {
super ( pattern ) ;
this . _bitapSearch = new BitapSearch ( pattern , {
location ,
threshold ,
distance ,
includeMatches ,
findAllMatches ,
minMatchCharLength ,
isCaseSensitive ,
ignoreLocation
} ) ;
}
static get type ( ) {
return "fuzzy" ;
}
static get multiRegex ( ) {
return /^"(.*)"$/ ;
}
static get singleRegex ( ) {
return /^(.*)$/ ;
}
search ( text2 ) {
return this . _bitapSearch . searchIn ( text2 ) ;
}
} ;
var IncludeMatch = class extends BaseMatch {
constructor ( pattern ) {
super ( pattern ) ;
}
static get type ( ) {
return "include" ;
}
static get multiRegex ( ) {
return /^'"(.*)"$/ ;
}
static get singleRegex ( ) {
return /^'(.*)$/ ;
}
search ( text2 ) {
let location = 0 ;
let index ;
const indices = [ ] ;
const patternLen = this . pattern . length ;
while ( ( index = text2 . indexOf ( this . pattern , location ) ) > - 1 ) {
location = index + patternLen ;
indices . push ( [ index , location - 1 ] ) ;
}
const isMatch = ! ! indices . length ;
return {
isMatch ,
score : isMatch ? 0 : 1 ,
indices
} ;
}
} ;
var searchers = [
ExactMatch ,
IncludeMatch ,
PrefixExactMatch ,
InversePrefixExactMatch ,
InverseSuffixExactMatch ,
SuffixExactMatch ,
InverseExactMatch ,
FuzzyMatch
] ;
var searchersLen = searchers . length ;
var SPACE _RE = / +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/ ;
var OR _TOKEN = "|" ;
function parseQuery ( pattern , options = { } ) {
return pattern . split ( OR _TOKEN ) . map ( ( item ) => {
let query = item . trim ( ) . split ( SPACE _RE ) . filter ( ( item2 ) => item2 && ! ! item2 . trim ( ) ) ;
let results = [ ] ;
for ( let i = 0 , len = query . length ; i < len ; i += 1 ) {
const queryItem = query [ i ] ;
let found = false ;
let idx = - 1 ;
while ( ! found && ++ idx < searchersLen ) {
const searcher = searchers [ idx ] ;
let token = searcher . isMultiMatch ( queryItem ) ;
if ( token ) {
results . push ( new searcher ( token , options ) ) ;
found = true ;
}
}
if ( found ) {
continue ;
}
idx = - 1 ;
while ( ++ idx < searchersLen ) {
const searcher = searchers [ idx ] ;
let token = searcher . isSingleMatch ( queryItem ) ;
if ( token ) {
results . push ( new searcher ( token , options ) ) ;
break ;
}
}
}
return results ;
} ) ;
}
var MultiMatchSet = /* @__PURE__ */ new Set ( [ FuzzyMatch . type , IncludeMatch . type ] ) ;
var ExtendedSearch = class {
constructor ( pattern , {
isCaseSensitive = Config . isCaseSensitive ,
includeMatches = Config . includeMatches ,
minMatchCharLength = Config . minMatchCharLength ,
ignoreLocation = Config . ignoreLocation ,
findAllMatches = Config . findAllMatches ,
location = Config . location ,
threshold = Config . threshold ,
distance = Config . distance
} = { } ) {
this . query = null ;
this . options = {
isCaseSensitive ,
includeMatches ,
minMatchCharLength ,
findAllMatches ,
ignoreLocation ,
location ,
threshold ,
distance
} ;
this . pattern = isCaseSensitive ? pattern : pattern . toLowerCase ( ) ;
this . query = parseQuery ( this . pattern , this . options ) ;
}
static condition ( _ , options ) {
return options . useExtendedSearch ;
}
searchIn ( text2 ) {
const query = this . query ;
if ( ! query ) {
return {
isMatch : false ,
score : 1
} ;
}
const { includeMatches , isCaseSensitive } = this . options ;
text2 = isCaseSensitive ? text2 : text2 . toLowerCase ( ) ;
let numMatches = 0 ;
let allIndices = [ ] ;
let totalScore = 0 ;
for ( let i = 0 , qLen = query . length ; i < qLen ; i += 1 ) {
const searchers2 = query [ i ] ;
allIndices . length = 0 ;
numMatches = 0 ;
for ( let j = 0 , pLen = searchers2 . length ; j < pLen ; j += 1 ) {
const searcher = searchers2 [ j ] ;
const { isMatch , indices , score } = searcher . search ( text2 ) ;
if ( isMatch ) {
numMatches += 1 ;
totalScore += score ;
if ( includeMatches ) {
const type = searcher . constructor . type ;
if ( MultiMatchSet . has ( type ) ) {
allIndices = [ ... allIndices , ... indices ] ;
} else {
allIndices . push ( indices ) ;
}
}
} else {
totalScore = 0 ;
numMatches = 0 ;
allIndices . length = 0 ;
break ;
}
}
if ( numMatches ) {
let result = {
isMatch : true ,
score : totalScore / numMatches
} ;
if ( includeMatches ) {
result . indices = allIndices ;
}
return result ;
}
}
return {
isMatch : false ,
score : 1
} ;
}
} ;
var registeredSearchers = [ ] ;
function register ( ... args ) {
registeredSearchers . push ( ... args ) ;
}
function createSearcher ( pattern , options ) {
for ( let i = 0 , len = registeredSearchers . length ; i < len ; i += 1 ) {
let searcherClass = registeredSearchers [ i ] ;
if ( searcherClass . condition ( pattern , options ) ) {
return new searcherClass ( pattern , options ) ;
}
}
return new BitapSearch ( pattern , options ) ;
}
var LogicalOperator = {
AND : "$and" ,
OR : "$or"
} ;
var KeyType = {
PATH : "$path" ,
PATTERN : "$val"
} ;
var isExpression = ( query ) => ! ! ( query [ LogicalOperator . AND ] || query [ LogicalOperator . OR ] ) ;
var isPath = ( query ) => ! ! query [ KeyType . PATH ] ;
var isLeaf = ( query ) => ! isArray ( query ) && isObject ( query ) && ! isExpression ( query ) ;
var convertToExplicit = ( query ) => ( {
[ LogicalOperator . AND ] : Object . keys ( query ) . map ( ( key ) => ( {
[ key ] : query [ key ]
} ) )
} ) ;
function parse ( query , options , { auto = true } = { } ) {
const next = ( query2 ) => {
let keys = Object . keys ( query2 ) ;
const isQueryPath = isPath ( query2 ) ;
if ( ! isQueryPath && keys . length > 1 && ! isExpression ( query2 ) ) {
return next ( convertToExplicit ( query2 ) ) ;
}
if ( isLeaf ( query2 ) ) {
const key = isQueryPath ? query2 [ KeyType . PATH ] : keys [ 0 ] ;
const pattern = isQueryPath ? query2 [ KeyType . PATTERN ] : query2 [ key ] ;
if ( ! isString ( pattern ) ) {
throw new Error ( LOGICAL _SEARCH _INVALID _QUERY _FOR _KEY ( key ) ) ;
}
const obj = {
keyId : createKeyId ( key ) ,
pattern
} ;
if ( auto ) {
obj . searcher = createSearcher ( pattern , options ) ;
}
return obj ;
}
let node = {
children : [ ] ,
operator : keys [ 0 ]
} ;
keys . forEach ( ( key ) => {
const value = query2 [ key ] ;
if ( isArray ( value ) ) {
value . forEach ( ( item ) => {
node . children . push ( next ( item ) ) ;
} ) ;
}
} ) ;
return node ;
} ;
if ( ! isExpression ( query ) ) {
query = convertToExplicit ( query ) ;
}
return next ( query ) ;
}
function computeScore ( results , { ignoreFieldNorm = Config . ignoreFieldNorm } ) {
results . forEach ( ( result ) => {
let totalScore = 1 ;
result . matches . forEach ( ( { key , norm : norm2 , score } ) => {
const weight = key ? key . weight : null ;
totalScore *= Math . pow ( score === 0 && weight ? Number . EPSILON : score , ( weight || 1 ) * ( ignoreFieldNorm ? 1 : norm2 ) ) ;
} ) ;
result . score = totalScore ;
} ) ;
}
function transformMatches ( result , data ) {
const matches = result . matches ;
data . matches = [ ] ;
if ( ! isDefined ( matches ) ) {
return ;
}
matches . forEach ( ( match ) => {
if ( ! isDefined ( match . indices ) || ! match . indices . length ) {
return ;
}
const { indices , value } = match ;
let obj = {
indices ,
value
} ;
if ( match . key ) {
obj . key = match . key . src ;
}
if ( match . idx > - 1 ) {
obj . refIndex = match . idx ;
}
data . matches . push ( obj ) ;
} ) ;
}
function transformScore ( result , data ) {
data . score = result . score ;
}
function format ( results , docs , {
includeMatches = Config . includeMatches ,
includeScore = Config . includeScore
} = { } ) {
const transformers = [ ] ;
if ( includeMatches )
transformers . push ( transformMatches ) ;
if ( includeScore )
transformers . push ( transformScore ) ;
return results . map ( ( result ) => {
const { idx } = result ;
const data = {
item : docs [ idx ] ,
refIndex : idx
} ;
if ( transformers . length ) {
transformers . forEach ( ( transformer ) => {
transformer ( result , data ) ;
} ) ;
}
return data ;
} ) ;
}
var Fuse = class {
constructor ( docs , options = { } , index ) {
this . options = _ _spreadValues ( _ _spreadValues ( { } , Config ) , options ) ;
if ( this . options . useExtendedSearch && false ) {
throw new Error ( EXTENDED _SEARCH _UNAVAILABLE ) ;
}
this . _keyStore = new KeyStore ( this . options . keys ) ;
this . setCollection ( docs , index ) ;
}
setCollection ( docs , index ) {
this . _docs = docs ;
if ( index && ! ( index instanceof FuseIndex ) ) {
throw new Error ( INCORRECT _INDEX _TYPE ) ;
}
this . _myIndex = index || createIndex ( this . options . keys , this . _docs , {
getFn : this . options . getFn ,
fieldNormWeight : this . options . fieldNormWeight
} ) ;
}
add ( doc ) {
if ( ! isDefined ( doc ) ) {
return ;
}
this . _docs . push ( doc ) ;
this . _myIndex . add ( doc ) ;
}
remove ( predicate = ( ) => false ) {
const results = [ ] ;
for ( let i = 0 , len = this . _docs . length ; i < len ; i += 1 ) {
const doc = this . _docs [ i ] ;
if ( predicate ( doc , i ) ) {
this . removeAt ( i ) ;
i -= 1 ;
len -= 1 ;
results . push ( doc ) ;
}
}
return results ;
}
removeAt ( idx ) {
this . _docs . splice ( idx , 1 ) ;
this . _myIndex . removeAt ( idx ) ;
}
getIndex ( ) {
return this . _myIndex ;
}
search ( query , { limit = - 1 } = { } ) {
const {
includeMatches ,
includeScore ,
shouldSort ,
sortFn ,
ignoreFieldNorm
} = this . options ;
let results = isString ( query ) ? isString ( this . _docs [ 0 ] ) ? this . _searchStringList ( query ) : this . _searchObjectList ( query ) : this . _searchLogical ( query ) ;
computeScore ( results , { ignoreFieldNorm } ) ;
if ( shouldSort ) {
results . sort ( sortFn ) ;
}
if ( isNumber ( limit ) && limit > - 1 ) {
results = results . slice ( 0 , limit ) ;
}
return format ( results , this . _docs , {
includeMatches ,
includeScore
} ) ;
}
_searchStringList ( query ) {
const searcher = createSearcher ( query , this . options ) ;
const { records } = this . _myIndex ;
const results = [ ] ;
records . forEach ( ( { v : text2 , i : idx , n : norm2 } ) => {
if ( ! isDefined ( text2 ) ) {
return ;
}
const { isMatch , score , indices } = searcher . searchIn ( text2 ) ;
if ( isMatch ) {
results . push ( {
item : text2 ,
idx ,
matches : [ { score , value : text2 , norm : norm2 , indices } ]
} ) ;
}
} ) ;
return results ;
}
_searchLogical ( query ) {
const expression = parse ( query , this . options ) ;
const evaluate = ( node , item , idx ) => {
if ( ! node . children ) {
const { keyId , searcher } = node ;
const matches = this . _findMatches ( {
key : this . _keyStore . get ( keyId ) ,
value : this . _myIndex . getValueForItemAtKeyId ( item , keyId ) ,
searcher
} ) ;
if ( matches && matches . length ) {
return [
{
idx ,
item ,
matches
}
] ;
}
return [ ] ;
}
const res = [ ] ;
for ( let i = 0 , len = node . children . length ; i < len ; i += 1 ) {
const child = node . children [ i ] ;
const result = evaluate ( child , item , idx ) ;
if ( result . length ) {
res . push ( ... result ) ;
} else if ( node . operator === LogicalOperator . AND ) {
return [ ] ;
}
}
return res ;
} ;
const records = this . _myIndex . records ;
const resultMap = { } ;
const results = [ ] ;
records . forEach ( ( { $ : item , i : idx } ) => {
if ( isDefined ( item ) ) {
let expResults = evaluate ( expression , item , idx ) ;
if ( expResults . length ) {
if ( ! resultMap [ idx ] ) {
resultMap [ idx ] = { idx , item , matches : [ ] } ;
results . push ( resultMap [ idx ] ) ;
}
expResults . forEach ( ( { matches } ) => {
resultMap [ idx ] . matches . push ( ... matches ) ;
} ) ;
}
}
} ) ;
return results ;
}
_searchObjectList ( query ) {
const searcher = createSearcher ( query , this . options ) ;
const { keys , records } = this . _myIndex ;
const results = [ ] ;
records . forEach ( ( { $ : item , i : idx } ) => {
if ( ! isDefined ( item ) ) {
return ;
}
let matches = [ ] ;
keys . forEach ( ( key , keyIndex ) => {
matches . push ( ... this . _findMatches ( {
key ,
value : item [ keyIndex ] ,
searcher
} ) ) ;
} ) ;
if ( matches . length ) {
results . push ( {
idx ,
item ,
matches
} ) ;
}
} ) ;
return results ;
}
_findMatches ( { key , value , searcher } ) {
if ( ! isDefined ( value ) ) {
return [ ] ;
}
let matches = [ ] ;
if ( isArray ( value ) ) {
value . forEach ( ( { v : text2 , i : idx , n : norm2 } ) => {
if ( ! isDefined ( text2 ) ) {
return ;
}
const { isMatch , score , indices } = searcher . searchIn ( text2 ) ;
if ( isMatch ) {
matches . push ( {
score ,
key ,
value : text2 ,
idx ,
norm : norm2 ,
indices
} ) ;
}
} ) ;
} else {
const { v : text2 , n : norm2 } = value ;
const { isMatch , score , indices } = searcher . searchIn ( text2 ) ;
if ( isMatch ) {
matches . push ( { score , key , value : text2 , norm : norm2 , indices } ) ;
}
}
return matches ;
}
} ;
Fuse . version = "6.6.2" ;
Fuse . createIndex = createIndex ;
Fuse . parseIndex = parseIndex ;
Fuse . config = Config ;
{
Fuse . parseQuery = parse ;
}
{
register ( ExtendedSearch ) ;
}
// src/utility/getUrlExtension.ts
function getUrlExtension ( url ) {
const regexp = new RegExp ( /\.([0-9a-z]+)(?:[?#]|$)/i ) ;
const match = regexp . exec ( url ) ;
if ( ! match ) {
return "" ;
}
const [ , extension ] = match ;
return extension ;
}
// src/TemplateEngine.ts
function useTemplateEngine ( ) {
const tags = { } ;
function addTag ( tag , value ) {
tags [ tag ] = value ;
}
function replacer ( template ) {
return template . replace ( /\{\{(.*?)(:\s*?.+?)?\}\}/g , ( match , tagId , params ) => {
const tagValue = tags [ tagId . toLowerCase ( ) ] ;
if ( tagValue === null || tagValue === void 0 ) {
const fuse = new Fuse ( Object . keys ( tags ) , {
shouldSort : true ,
findAllMatches : false ,
threshold : 0.4 ,
isCaseSensitive : false
} ) ;
const similarTag = fuse . search ( tagId ) ;
new import _obsidian9 . Notice ( ` Tag ${ tagId } is invalid. ${ similarTag . length > 0 ? ` Did you mean ${ similarTag [ 0 ] . item } ? ` : "" } ` ) ;
return match ;
}
if ( typeof tagValue === "function" ) {
if ( params ) {
const splitParams = params . slice ( 1 ) . split ( "," ) ;
const args = Array . isArray ( splitParams ) ? splitParams : [ params ] ;
return tagValue ( ... args ) ;
}
return tagValue ( ) ;
}
return tagValue ;
} ) ;
}
return [ replacer , addTag ] ;
}
function NoteTemplateEngine ( template , episode ) {
var _a ;
const [ replacer , addTag ] = useTemplateEngine ( ) ;
addTag ( "title" , episode . title ) ;
addTag ( "description" , ( prependToLines ) => {
if ( prependToLines ) {
return ( 0 , import _obsidian9 . htmlToMarkdown ) ( episode . description ) . split ( "\n" ) . map ( ( str ) => ` ${ prependToLines } ${ str } ` ) . join ( "\n" ) ;
}
return ( 0 , import _obsidian9 . htmlToMarkdown ) ( episode . description ) ;
} ) ;
addTag ( "content" , ( prependToLines ) => {
if ( prependToLines ) {
return ( 0 , import _obsidian9 . htmlToMarkdown ) ( episode . content ) . split ( "\n" ) . map ( ( str ) => ` ${ prependToLines } ${ str } ` ) . join ( "\n" ) ;
}
return ( 0 , import _obsidian9 . htmlToMarkdown ) ( episode . content ) ;
} ) ;
addTag ( "safetitle" , replaceIllegalFileNameCharactersInString ( episode . title ) ) ;
addTag ( "url" , episode . url ) ;
addTag ( "date" , ( format2 ) => episode . episodeDate ? window . moment ( episode . episodeDate ) . format ( format2 != null ? format2 : "YYYY-MM-DD" ) : "" ) ;
addTag ( "podcast" , episode . podcastName ) ;
addTag ( "artwork" , ( _a = episode . artworkUrl ) != null ? _a : "" ) ;
return replacer ( template ) ;
}
function TimestampTemplateEngine ( template ) {
const [ replacer , addTag ] = useTemplateEngine ( ) ;
addTag ( "time" , ( format2 ) => get _store _value ( plugin ) . api . getPodcastTimeFormatted ( format2 != null ? format2 : "HH:mm:ss" ) ) ;
addTag ( "linktime" , ( format2 ) => get _store _value ( plugin ) . api . getPodcastTimeFormatted ( format2 != null ? format2 : "HH:mm:ss" , true ) ) ;
return replacer ( template ) ;
}
function FilePathTemplateEngine ( template , episode ) {
const [ replacer , addTag ] = useTemplateEngine ( ) ;
addTag ( "title" , ( whitespaceReplacement ) => {
const legalTitle = replaceIllegalFileNameCharactersInString ( episode . title ) ;
if ( whitespaceReplacement ) {
return legalTitle . replace ( /\s+/g , whitespaceReplacement ) ;
}
return legalTitle ;
} ) ;
addTag ( "podcast" , ( whitespaceReplacement ) => {
const legalName = replaceIllegalFileNameCharactersInString ( episode . podcastName ) ;
if ( whitespaceReplacement ) {
return legalName . replace ( /\s+/g , whitespaceReplacement ) ;
}
return legalName ;
} ) ;
addTag ( "date" , ( format2 ) => episode . episodeDate ? window . moment ( episode . episodeDate ) . format ( format2 != null ? format2 : "YYYY-MM-DD" ) : "" ) ;
return replacer ( template ) ;
}
function DownloadPathTemplateEngine ( template , episode ) {
const templateExtension = getUrlExtension ( template ) ;
const templateWithoutExtension = templateExtension ? template . replace ( templateExtension , "" ) : template ;
const [ replacer , addTag ] = useTemplateEngine ( ) ;
addTag ( "title" , ( whitespaceReplacement ) => {
const legalTitle = replaceIllegalFileNameCharactersInString ( episode . title ) ;
if ( whitespaceReplacement ) {
return legalTitle . replace ( /\s+/g , whitespaceReplacement ) ;
}
return legalTitle ;
} ) ;
addTag ( "podcast" , ( whitespaceReplacement ) => {
const legalName = replaceIllegalFileNameCharactersInString ( episode . podcastName ) ;
if ( whitespaceReplacement ) {
return legalName . replace ( /\s+/g , whitespaceReplacement ) ;
}
return legalName ;
} ) ;
addTag ( "date" , ( format2 ) => episode . episodeDate ? window . moment ( episode . episodeDate ) . format ( format2 != null ? format2 : "YYYY-MM-DD" ) : "" ) ;
return replacer ( templateWithoutExtension ) ;
}
function replaceIllegalFileNameCharactersInString ( string ) {
return string . replace ( /[\\,#%&{}/*<>$'":@\u2023|?]*/g , "" ) . replace ( /\n/ , " " ) . replace ( " " , " " ) ;
}
// src/opml.ts
var import _obsidian10 = require ( "obsidian" ) ;
function importOPML ( targetFile ) {
return _ _async ( this , null , function * ( ) {
const fileContent = yield app . vault . cachedRead ( targetFile ) ;
const dp = new DOMParser ( ) ;
const dom = dp . parseFromString ( fileContent , "application/xml" ) ;
const podcastEntryNodes = dom . querySelectorAll ( "outline[text][xmlUrl]" ) ;
const incompletePodcastsToAdd = [ ] ;
for ( let i = 0 ; i < podcastEntryNodes . length ; i ++ ) {
const node = podcastEntryNodes . item ( i ) ;
const text2 = node . getAttribute ( "text" ) ;
const xmlUrl = node . getAttribute ( "xmlUrl" ) ;
if ( ! text2 || ! xmlUrl ) {
continue ;
}
incompletePodcastsToAdd . push ( {
title : text2 ,
url : xmlUrl
} ) ;
}
const podcasts = yield Promise . all ( incompletePodcastsToAdd . map ( ( feed ) => _ _async ( this , null , function * ( ) {
return new FeedParser ( ) . getFeed ( feed . url ) ;
} ) ) ) ;
savedFeeds . update ( ( feeds ) => {
for ( const pod of podcasts ) {
if ( feeds [ pod . title ] )
continue ;
feeds [ pod . title ] = structuredClone ( pod ) ;
}
return feeds ;
} ) ;
new import _obsidian10 . Notice ( ` ${ targetFile . name } ingested. Saved ${ podcasts . length } / ${ incompletePodcastsToAdd . length } podcasts. ` ) ;
if ( podcasts . length !== incompletePodcastsToAdd . length ) {
const missingPodcasts = incompletePodcastsToAdd . filter ( ( pod ) => ! podcasts . find ( ( v ) => v . url === pod . url ) ) ;
for ( const missingPod of missingPodcasts ) {
new import _obsidian10 . Notice ( ` Failed to save ${ missingPod . title } ... ` , 6e4 ) ;
}
}
} ) ;
}
function exportOPML ( feeds , filePath = "PodNotes_Export.opml" ) {
return _ _async ( this , null , function * ( ) {
const header = ` <?xml version="1.0" encoding="utf=8" standalone="no"?> ` ;
const opml = ( child ) => ` <opml version="1.0"> ${ child } </opml> ` ;
const head = ( child ) => ` <head> ${ child } </head> ` ;
const title = ` <title>PodNotes Feeds</title> ` ;
const body = ( child ) => ` <body> ${ child } </body> ` ;
const feedOutline = ( feed ) => ` <outline text=" ${ feed . title } " type="rss" xmlUrl=" ${ feed . url } " /> ` ;
const feedsOutline = ( _feeds ) => ` <outline text="feeds"> ${ feeds . map ( feedOutline ) . join ( "" ) } </outline> ` ;
const doc = header + opml ( ` ${ head ( title ) }
$ { body ( feedsOutline ( feeds ) ) } ` );
try {
yield app . vault . create ( filePath , doc ) ;
new import _obsidian10 . Notice ( ` Exported ${ feeds . length } podcast feeds to file " ${ filePath } ". ` ) ;
} catch ( error ) {
new import _obsidian10 . Notice ( ` Unable to create podcast export file:
$ { error } ` );
console . error ( error ) ;
}
} ) ;
}
// src/ui/settings/PodNotesSettingsTab.ts
var PodNotesSettingsTab = class extends import _obsidian11 . PluginSettingTab {
constructor ( app2 , plugin2 ) {
super ( app2 , plugin2 ) ;
this . plugin = plugin2 ;
this . settingsTab = this ;
}
display ( ) {
const { containerEl } = this ;
containerEl . empty ( ) ;
const header = containerEl . createEl ( "h2" , { text : "PodNotes" } ) ;
header . style . textAlign = "center" ;
const settingsContainer = containerEl . createDiv ( ) ;
settingsContainer . classList . add ( "settings-container" ) ;
new import _obsidian11 . Setting ( settingsContainer ) . setName ( "Search Podcasts" ) . setHeading ( ) . setDesc ( "Search for podcasts by name or custom feed URL." ) ;
const queryGridContainer = settingsContainer . createDiv ( ) ;
this . podcastQueryGrid = new PodcastQueryGrid _default ( {
target : queryGridContainer
} ) ;
new import _obsidian11 . Setting ( settingsContainer ) . setName ( "Playlists" ) . setHeading ( ) . setDesc ( ` Add playlists to gather podcast episodes. ` ) ;
const playlistManagerContainer = settingsContainer . createDiv ( ) ;
this . playlistManager = new PlaylistManager _default ( {
target : playlistManagerContainer
} ) ;
this . addDefaultPlaybackRateSetting ( settingsContainer ) ;
this . addSkipLengthSettings ( settingsContainer ) ;
this . addNoteSettings ( settingsContainer ) ;
this . addDownloadSettings ( settingsContainer ) ;
this . addImportSettings ( settingsContainer ) ;
this . addExportSettings ( settingsContainer ) ;
}
hide ( ) {
var _a , _b ;
( _a = this . podcastQueryGrid ) == null ? void 0 : _a . $destroy ( ) ;
( _b = this . playlistManager ) == null ? void 0 : _b . $destroy ( ) ;
}
addDefaultPlaybackRateSetting ( container ) {
new import _obsidian11 . Setting ( container ) . setName ( "Default Playback Rate" ) . addSlider ( ( slider ) => slider . setLimits ( 0.5 , 4 , 0.1 ) . setValue ( this . plugin . settings . defaultPlaybackRate ) . onChange ( ( value ) => {
this . plugin . settings . defaultPlaybackRate = value ;
this . plugin . saveSettings ( ) ;
} ) . setDynamicTooltip ( ) ) ;
}
addSkipLengthSettings ( container ) {
new import _obsidian11 . Setting ( container ) . setName ( "Skip backward length (s)" ) . addText ( ( textComponent ) => {
textComponent . inputEl . type = "number" ;
textComponent . setValue ( ` ${ this . plugin . settings . skipBackwardLength } ` ) . onChange ( ( value ) => {
this . plugin . settings . skipBackwardLength = parseInt ( value ) ;
this . plugin . saveSettings ( ) ;
} ) . setPlaceholder ( "seconds" ) ;
} ) ;
new import _obsidian11 . Setting ( container ) . setName ( "Skip forward length (s)" ) . addText ( ( textComponent ) => {
textComponent . inputEl . type = "number" ;
textComponent . setValue ( ` ${ this . plugin . settings . skipForwardLength } ` ) . onChange ( ( value ) => {
this . plugin . settings . skipForwardLength = parseInt ( value ) ;
this . plugin . saveSettings ( ) ;
} ) . setPlaceholder ( "seconds" ) ;
} ) ;
}
addNoteSettings ( settingsContainer ) {
const container = settingsContainer . createDiv ( ) ;
container . createEl ( "h4" , { text : "Note settings" } ) ;
const timestampSetting = new import _obsidian11 . Setting ( container ) . setName ( "Capture timestamp format" ) . setHeading ( ) . addTextArea ( ( textArea ) => {
textArea . setValue ( this . plugin . settings . timestamp . template ) ;
textArea . setPlaceholder ( "- {{linktime}} " ) ;
textArea . onChange ( ( value ) => {
this . plugin . settings . timestamp . template = value ;
this . plugin . saveSettings ( ) ;
updateTimestampDemo ( value ) ;
} ) ;
textArea . inputEl . style . width = "100%" ;
} ) ;
timestampSetting . settingEl . style . flexDirection = "column" ;
timestampSetting . settingEl . style . alignItems = "unset" ;
timestampSetting . settingEl . style . gap = "10px" ;
const timestampFormatDemoEl = container . createDiv ( ) ;
const updateTimestampDemo = ( value ) => {
if ( ! this . plugin . api . podcast )
return ;
const demoVal = TimestampTemplateEngine ( value ) ;
timestampFormatDemoEl . empty ( ) ;
import _obsidian11 . MarkdownRenderer . renderMarkdown ( demoVal , timestampFormatDemoEl , "" , null ) ;
} ;
updateTimestampDemo ( this . plugin . settings . timestamp . template ) ;
const randomEpisode = getRandomEpisode ( ) ;
const noteCreationFilePathSetting = new import _obsidian11 . Setting ( container ) . setName ( "Note creation file path" ) . setHeading ( ) . addText ( ( textComponent ) => {
textComponent . setValue ( this . plugin . settings . note . path ) ;
textComponent . setPlaceholder ( "inputs/podcasts/{{podcast}} - {{title}}.md" ) ;
textComponent . onChange ( ( value ) => {
this . plugin . settings . note . path = value ;
this . plugin . saveSettings ( ) ;
const demoVal = FilePathTemplateEngine ( value , randomEpisode ) ;
noteCreationFilePathDemoEl . empty ( ) ;
import _obsidian11 . MarkdownRenderer . renderMarkdown ( demoVal , noteCreationFilePathDemoEl , "" , null ) ;
} ) ;
textComponent . inputEl . style . width = "100%" ;
} ) ;
noteCreationFilePathSetting . settingEl . style . flexDirection = "column" ;
noteCreationFilePathSetting . settingEl . style . alignItems = "unset" ;
noteCreationFilePathSetting . settingEl . style . gap = "10px" ;
const noteCreationFilePathDemoEl = container . createDiv ( ) ;
const noteCreationSetting = new import _obsidian11 . Setting ( container ) . setName ( "Note creation template" ) . setHeading ( ) . addTextArea ( ( textArea ) => {
textArea . setValue ( this . plugin . settings . note . template ) ;
textArea . onChange ( ( value ) => {
this . plugin . settings . note . template = value ;
this . plugin . saveSettings ( ) ;
} ) ;
textArea . inputEl . style . width = "100%" ;
textArea . inputEl . style . height = "25vh" ;
textArea . setPlaceholder ( "## {{title}}\n![]({{artwork}})\n### Metadata\nPodcast:: {{podcast}}\nEpisode:: {{title}}\nPublishDate:: {{date:YYYY-MM-DD}}\n### Description\n> {{description}}" ) ;
} ) ;
noteCreationSetting . settingEl . style . flexDirection = "column" ;
noteCreationSetting . settingEl . style . alignItems = "unset" ;
noteCreationSetting . settingEl . style . gap = "10px" ;
}
addDownloadSettings ( container ) {
container . createEl ( "h4" , { text : "Download settings" } ) ;
const randomEpisode = getRandomEpisode ( ) ;
const downloadPathSetting = new import _obsidian11 . Setting ( container ) . setName ( "Episode download path" ) . setDesc ( "The path where the episode will be downloaded to. Avoid setting an extension, as it will be added automatically." ) . setHeading ( ) . addText ( ( textComponent ) => {
textComponent . setValue ( this . plugin . settings . download . path ) ;
textComponent . setPlaceholder ( "inputs/podcasts/{{podcast}} - {{title}}" ) ;
textComponent . onChange ( ( value ) => {
this . plugin . settings . download . path = value ;
this . plugin . saveSettings ( ) ;
const demoVal = DownloadPathTemplateEngine ( value , randomEpisode ) ;
downloadFilePathDemoEl . empty ( ) ;
import _obsidian11 . MarkdownRenderer . renderMarkdown ( ` ${ demoVal } .mp3 ` , downloadFilePathDemoEl , "" , null ) ;
} ) ;
textComponent . inputEl . style . width = "100%" ;
} ) ;
downloadPathSetting . settingEl . style . flexDirection = "column" ;
downloadPathSetting . settingEl . style . alignItems = "unset" ;
downloadPathSetting . settingEl . style . gap = "10px" ;
const downloadFilePathDemoEl = container . createDiv ( ) ;
}
addImportSettings ( settingsContainer ) {
const setting = new import _obsidian11 . Setting ( settingsContainer ) ;
const opmlFiles = app . vault . getAllLoadedFiles ( ) . filter ( ( file ) => file instanceof import _obsidian11 . TFile && file . extension . toLowerCase ( ) . endsWith ( "opml" ) ) ;
const detectedOpmlFile = opmlFiles [ 0 ] ;
let value = detectedOpmlFile ? detectedOpmlFile . path : "" ;
setting . setName ( "Import" ) . setDesc ( "Import podcasts from other services with OPML files." ) ;
setting . addText ( ( text2 ) => {
text2 . setPlaceholder ( detectedOpmlFile ? detectedOpmlFile . path : "path to opml file" ) ;
text2 . onChange ( ( v ) => value = v ) ;
text2 . setValue ( value ) ;
} ) ;
setting . addButton ( ( importBtn ) => importBtn . setButtonText ( "Import" ) . onClick ( ( ) => {
const inputFile = app . vault . getAbstractFileByPath ( value ) ;
if ( ! inputFile || ! ( inputFile instanceof import _obsidian11 . TFile ) ) {
new import _obsidian11 . Notice ( ` Invalid file path, could not find opml file at location " ${ value } ". ` ) ;
return ;
}
new import _obsidian11 . Notice ( "Starting import..." ) ;
importOPML ( inputFile ) ;
} ) ) ;
}
addExportSettings ( settingsContainer ) {
const setting = new import _obsidian11 . Setting ( settingsContainer ) ;
setting . setName ( "Export" ) . setDesc ( "Export saved podcast feeds to OPML file." ) ;
let value = "PodNotes_Export.opml" ;
setting . addText ( ( text2 ) => {
text2 . setPlaceholder ( "Target path" ) ;
text2 . onChange ( ( v ) => value = v ) ;
text2 . setValue ( value ) ;
} ) ;
setting . addButton ( ( btn ) => btn . setButtonText ( "Export" ) . onClick ( ( ) => {
const feeds = Object . values ( get _store _value ( savedFeeds ) ) ;
if ( feeds . length === 0 ) {
new import _obsidian11 . Notice ( "Nothing to export." ) ;
return ;
}
exportOPML ( feeds , value . endsWith ( ".opml" ) ? value : ` ${ value } .opml ` ) ;
} ) ) ;
}
} ;
function getRandomEpisode ( ) {
const fallbackDemoObj = {
description : "demo" ,
content : "demo" ,
podcastName : "demo" ,
title : "demo" ,
url : "demo" ,
artworkUrl : "demo" ,
streamUrl : "demo" ,
episodeDate : new Date ( ) ,
feedUrl : "demo"
} ;
const feedEpisodes = Object . values ( get _store _value ( episodeCache ) ) ;
if ( ! feedEpisodes . length )
return fallbackDemoObj ;
const randomFeed = feedEpisodes [ Math . floor ( Math . random ( ) * feedEpisodes . length ) ] ;
if ( ! randomFeed . length )
return fallbackDemoObj ;
const randomEpisode = randomFeed [ Math . floor ( Math . random ( ) * randomFeed . length ) ] ;
return randomEpisode ;
}
// src/ui/PodcastView/index.ts
var import _obsidian18 = require ( "obsidian" ) ;
// src/ui/PodcastView/PlaylistCard.svelte
function add _css6 ( target ) {
append _styles ( target , "svelte-r5cl0s" , ".playlist-card.svelte-r5cl0s{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%;cursor:pointer;border:1px solid var(--background-modifier-border);text-align:center;overflow:hidden}.playlist-card.svelte-r5cl0s:hover{background-color:var(--background-modifier-border)}" ) ;
}
function create _fragment9 ( ctx ) {
let div ;
let icon ;
let t0 ;
let span ;
let t1 ;
let t2 _value = ctx [ 0 ] . episodes . length + "" ;
let t2 ;
let t3 ;
let div _aria _label _value ;
let current ;
let mounted ;
let dispose ;
icon = new Icon _default ( {
props : {
icon : ctx [ 0 ] . icon ,
size : 40 ,
clickable : true
}
} ) ;
return {
c ( ) {
div = element ( "div" ) ;
create _component ( icon . $$ . fragment ) ;
t0 = space ( ) ;
span = element ( "span" ) ;
t1 = text ( "(" ) ;
t2 = text ( t2 _value ) ;
t3 = text ( ")" ) ;
attr ( div , "class" , "playlist-card svelte-r5cl0s" ) ;
attr ( div , "aria-label" , div _aria _label _value = ctx [ 0 ] . name ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( icon , div , null ) ;
append ( div , t0 ) ;
append ( div , span ) ;
append ( span , t1 ) ;
append ( span , t2 ) ;
append ( span , t3 ) ;
current = true ;
if ( ! mounted ) {
dispose = listen ( div , "click" , ctx [ 1 ] ) ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
const icon _changes = { } ;
if ( dirty & 1 )
icon _changes . icon = ctx2 [ 0 ] . icon ;
icon . $set ( icon _changes ) ;
if ( ( ! current || dirty & 1 ) && t2 _value !== ( t2 _value = ctx2 [ 0 ] . episodes . length + "" ) )
set _data ( t2 , t2 _value ) ;
if ( ! current || dirty & 1 && div _aria _label _value !== ( div _aria _label _value = ctx2 [ 0 ] . name ) ) {
attr ( div , "aria-label" , div _aria _label _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( icon ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function instance9 ( $$self , $$props , $$invalidate ) {
let { playlist } = $$props ;
const dispatch = createEventDispatcher ( ) ;
function onClickPlaylist ( event ) {
dispatch ( "clickPlaylist" , { playlist , event } ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "playlist" in $$props2 )
$$invalidate ( 0 , playlist = $$props2 . playlist ) ;
} ;
return [ playlist , onClickPlaylist ] ;
}
var PlaylistCard = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance9 , create _fragment9 , safe _not _equal , { playlist : 0 } , add _css6 ) ;
}
} ;
var PlaylistCard _default = PlaylistCard ;
// src/ui/common/Image.svelte
function add _css7 ( target ) {
append _styles ( target , "svelte-1uzaahv" , "img.svelte-1uzaahv:hover{cursor:pointer !important}.pn_image_container.svelte-1uzaahv{width:100%;height:100%;display:block;position:relative;overflow:hidden}" ) ;
}
var get _fallback _slot _changes = ( dirty ) => ( { } ) ;
var get _fallback _slot _context = ( ctx ) => ( { } ) ;
function create _if _block _1 ( ctx ) {
let current ;
const fallback _slot _template = ctx [ 10 ] . fallback ;
const fallback _slot = create _slot ( fallback _slot _template , ctx , ctx [ 9 ] , get _fallback _slot _context ) ;
return {
c ( ) {
if ( fallback _slot )
fallback _slot . c ( ) ;
} ,
m ( target , anchor ) {
if ( fallback _slot ) {
fallback _slot . m ( target , anchor ) ;
}
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( fallback _slot ) {
if ( fallback _slot . p && ( ! current || dirty & 512 ) ) {
update _slot _base ( fallback _slot , fallback _slot _template , ctx2 , ctx2 [ 9 ] , ! current ? get _all _dirty _from _scope ( ctx2 [ 9 ] ) : get _slot _changes ( fallback _slot _template , ctx2 [ 9 ] , dirty , get _fallback _slot _changes ) , get _fallback _slot _context ) ;
}
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( fallback _slot , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( fallback _slot , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( fallback _slot )
fallback _slot . d ( detaching ) ;
}
} ;
}
function create _if _block2 ( ctx ) {
let div ;
let img ;
let img _src _value ;
let img _class _value ;
let mounted ;
let dispose ;
return {
c ( ) {
div = element ( "div" ) ;
img = element ( "img" ) ;
attr ( img , "draggable" , "false" ) ;
if ( ! src _url _equal ( img . src , img _src _value = ctx [ 0 ] ) )
attr ( img , "src" , img _src _value ) ;
attr ( img , "alt" , ctx [ 1 ] ) ;
attr ( img , "class" , img _class _value = null _to _empty ( ctx [ 4 ] ) + " svelte-1uzaahv" ) ;
set _style ( img , "opacity" , ctx [ 3 ] ? ctx [ 3 ] : ! ctx [ 2 ] ? 1 : ctx [ 5 ] ? 1 : 0 , false ) ;
set _style ( img , "transition" , ctx [ 2 ] ? "opacity 0.5s ease-out" : "" , false ) ;
attr ( div , "class" , "pn_image_container svelte-1uzaahv" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
append ( div , img ) ;
if ( ! mounted ) {
dispose = [
listen ( img , "click" , ctx [ 11 ] ) ,
listen ( img , "load" , ctx [ 12 ] ) ,
listen ( img , "error" , ctx [ 13 ] )
] ;
mounted = true ;
}
} ,
p ( ctx2 , dirty ) {
if ( dirty & 1 && ! src _url _equal ( img . src , img _src _value = ctx2 [ 0 ] ) ) {
attr ( img , "src" , img _src _value ) ;
}
if ( dirty & 2 ) {
attr ( img , "alt" , ctx2 [ 1 ] ) ;
}
if ( dirty & 16 && img _class _value !== ( img _class _value = null _to _empty ( ctx2 [ 4 ] ) + " svelte-1uzaahv" ) ) {
attr ( img , "class" , img _class _value ) ;
}
if ( dirty & 44 ) {
set _style ( img , "opacity" , ctx2 [ 3 ] ? ctx2 [ 3 ] : ! ctx2 [ 2 ] ? 1 : ctx2 [ 5 ] ? 1 : 0 , false ) ;
}
if ( dirty & 4 ) {
set _style ( img , "transition" , ctx2 [ 2 ] ? "opacity 0.5s ease-out" : "" , false ) ;
}
} ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function create _fragment10 ( ctx ) {
let current _block _type _index ;
let if _block ;
let if _block _anchor ;
let current ;
const if _block _creators = [ create _if _block2 , create _if _block _1 ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx2 , dirty ) {
if ( ctx2 [ 6 ] || ctx2 [ 5 ] )
return 0 ;
if ( ctx2 [ 7 ] )
return 1 ;
return - 1 ;
}
if ( ~ ( current _block _type _index = select _block _type ( ctx , - 1 ) ) ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
}
return {
c ( ) {
if ( if _block )
if _block . c ( ) ;
if _block _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . m ( target , anchor ) ;
}
insert ( target , if _block _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type ( ctx2 , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . p ( ctx2 , dirty ) ;
}
} else {
if ( if _block ) {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
}
if ( ~ current _block _type _index ) {
if _block = if _blocks [ current _block _type _index ] ;
if ( ! if _block ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx2 ) ;
if _block . c ( ) ;
} else {
if _block . p ( ctx2 , dirty ) ;
}
transition _in ( if _block , 1 ) ;
if _block . m ( if _block _anchor . parentNode , if _block _anchor ) ;
} else {
if _block = null ;
}
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . d ( detaching ) ;
}
if ( detaching )
detach ( if _block _anchor ) ;
}
} ;
}
function instance10 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
let { src } = $$props ;
let { alt } = $$props ;
let { fadeIn = false } = $$props ;
let { opacity = 0 } = $$props ;
let { class : _class = "" } = $$props ;
let loaded = false ;
let loading = true ;
let failed = false ;
const dispatcher = createEventDispatcher ( ) ;
function onClick ( event ) {
dispatcher ( "click" , { event } ) ;
}
const click _handler = ( e ) => onClick ( e ) ;
const load _handler = ( ) => {
$$invalidate ( 5 , loaded = true ) ;
$$invalidate ( 6 , loading = false ) ;
} ;
const error _handler = ( ) => {
$$invalidate ( 7 , failed = true ) ;
$$invalidate ( 6 , loading = false ) ;
} ;
$$self . $$set = ( $$props2 ) => {
if ( "src" in $$props2 )
$$invalidate ( 0 , src = $$props2 . src ) ;
if ( "alt" in $$props2 )
$$invalidate ( 1 , alt = $$props2 . alt ) ;
if ( "fadeIn" in $$props2 )
$$invalidate ( 2 , fadeIn = $$props2 . fadeIn ) ;
if ( "opacity" in $$props2 )
$$invalidate ( 3 , opacity = $$props2 . opacity ) ;
if ( "class" in $$props2 )
$$invalidate ( 4 , _class = $$props2 . class ) ;
if ( "$$scope" in $$props2 )
$$invalidate ( 9 , $$scope = $$props2 . $$scope ) ;
} ;
return [
src ,
alt ,
fadeIn ,
opacity ,
_class ,
loaded ,
loading ,
failed ,
onClick ,
$$scope ,
slots ,
click _handler ,
load _handler ,
error _handler
] ;
}
var Image = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance10 , create _fragment10 , safe _not _equal , {
src : 0 ,
alt : 1 ,
fadeIn : 2 ,
opacity : 3 ,
class : 4
} , add _css7 ) ;
}
} ;
var Image _default = Image ;
// src/ui/PodcastView/PodcastGridCard.svelte
function add _css8 ( target ) {
append _styles ( target , "svelte-13t4swo" , ".podcast-image{width:100%;height:100%;cursor:pointer !important;object-fit:cover;background-size:cover;background-position:center;background-repeat:no-repeat;border:1px solid var(--background-modifier-border)}" ) ;
}
function create _fragment11 ( ctx ) {
let image ;
let current ;
image = new Image _default ( {
props : {
src : ctx [ 0 ] . artworkUrl ,
alt : ctx [ 0 ] . title ,
class : "podcast-image"
}
} ) ;
image . $on ( "click" , function ( ) {
if ( is _function ( ctx [ 1 ] . bind ( null , ctx [ 0 ] ) ) )
ctx [ 1 ] . bind ( null , ctx [ 0 ] ) . apply ( this , arguments ) ;
} ) ;
return {
c ( ) {
create _component ( image . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( image , target , anchor ) ;
current = true ;
} ,
p ( new _ctx , [ dirty ] ) {
ctx = new _ctx ;
const image _changes = { } ;
if ( dirty & 1 )
image _changes . src = ctx [ 0 ] . artworkUrl ;
if ( dirty & 1 )
image _changes . alt = ctx [ 0 ] . title ;
image . $set ( image _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( image . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( image . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( image , detaching ) ;
}
} ;
}
function instance11 ( $$self , $$props , $$invalidate ) {
let { feed } = $$props ;
const dispatch = createEventDispatcher ( ) ;
function onclickPodcast ( feed2 ) {
dispatch ( "clickPodcast" , { feed : feed2 } ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "feed" in $$props2 )
$$invalidate ( 0 , feed = $$props2 . feed ) ;
} ;
return [ feed , onclickPodcast ] ;
}
var PodcastGridCard = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance11 , create _fragment11 , safe _not _equal , { feed : 0 } , add _css8 ) ;
}
} ;
var PodcastGridCard _default = PodcastGridCard ;
// src/ui/PodcastView/PodcastGrid.svelte
function add _css9 ( target ) {
append _styles ( target , "svelte-1xbcyvn" , ".podcast-grid.svelte-1xbcyvn{display:grid;grid-template-columns:repeat(auto-fit, minmax(7rem, 1fr));grid-auto-flow:row;grid-auto-rows:1fr;grid-gap:0rem}" ) ;
}
function get _each _context3 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 5 ] = list [ i ] ;
return child _ctx ;
}
function get _each _context _1 ( ctx , list , i ) {
const child _ctx = ctx . slice ( ) ;
child _ctx [ 8 ] = list [ i ] ;
return child _ctx ;
}
function create _if _block _12 ( ctx ) {
let each _1 _anchor ;
let current ;
let each _value _1 = ctx [ 1 ] ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value _1 . length ; i += 1 ) {
each _blocks [ i ] = create _each _block _1 ( get _each _context _1 ( ctx , each _value _1 , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
return {
c ( ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
each _1 _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( target , anchor ) ;
}
insert ( target , each _1 _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( dirty & 6 ) {
each _value _1 = ctx2 [ 1 ] ;
let i ;
for ( i = 0 ; i < each _value _1 . length ; i += 1 ) {
const child _ctx = get _each _context _1 ( ctx2 , each _value _1 , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block _1 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( each _1 _anchor . parentNode , each _1 _anchor ) ;
}
}
group _outros ( ) ;
for ( i = each _value _1 . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
for ( let i = 0 ; i < each _value _1 . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
current = true ;
} ,
o ( local ) {
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
current = false ;
} ,
d ( detaching ) {
destroy _each ( each _blocks , detaching ) ;
if ( detaching )
detach ( each _1 _anchor ) ;
}
} ;
}
function create _each _block _1 ( ctx ) {
let playlistcard ;
let current ;
playlistcard = new PlaylistCard _default ( { props : { playlist : ctx [ 8 ] } } ) ;
playlistcard . $on ( "clickPlaylist" , ctx [ 2 ] ) ;
return {
c ( ) {
create _component ( playlistcard . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( playlistcard , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const playlistcard _changes = { } ;
if ( dirty & 2 )
playlistcard _changes . playlist = ctx2 [ 8 ] ;
playlistcard . $set ( playlistcard _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( playlistcard . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( playlistcard . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( playlistcard , detaching ) ;
}
} ;
}
function create _else _block ( ctx ) {
let div ;
return {
c ( ) {
div = element ( "div" ) ;
div . innerHTML = ` <p>No saved podcasts.</p> ` ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
}
} ;
}
function create _if _block3 ( ctx ) {
let each _1 _anchor ;
let current ;
let each _value = ctx [ 0 ] ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
each _blocks [ i ] = create _each _block3 ( get _each _context3 ( ctx , each _value , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
return {
c ( ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
each _1 _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( target , anchor ) ;
}
insert ( target , each _1 _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( dirty & 1 ) {
each _value = ctx2 [ 0 ] ;
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context3 ( ctx2 , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block3 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( each _1 _anchor . parentNode , each _1 _anchor ) ;
}
}
group _outros ( ) ;
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
current = true ;
} ,
o ( local ) {
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
current = false ;
} ,
d ( detaching ) {
destroy _each ( each _blocks , detaching ) ;
if ( detaching )
detach ( each _1 _anchor ) ;
}
} ;
}
function create _each _block3 ( ctx ) {
let podcastgridcard ;
let current ;
podcastgridcard = new PodcastGridCard _default ( { props : { feed : ctx [ 5 ] } } ) ;
podcastgridcard . $on ( "clickPodcast" , ctx [ 3 ] ) ;
return {
c ( ) {
create _component ( podcastgridcard . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( podcastgridcard , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const podcastgridcard _changes = { } ;
if ( dirty & 1 )
podcastgridcard _changes . feed = ctx2 [ 5 ] ;
podcastgridcard . $set ( podcastgridcard _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( podcastgridcard . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( podcastgridcard . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( podcastgridcard , detaching ) ;
}
} ;
}
function create _fragment12 ( ctx ) {
let div ;
let t ;
let current _block _type _index ;
let if _block1 ;
let current ;
let if _block0 = ctx [ 1 ] . length > 0 && create _if _block _12 ( ctx ) ;
const if _block _creators = [ create _if _block3 , create _else _block ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx2 , dirty ) {
if ( ctx2 [ 0 ] . length > 0 )
return 0 ;
return 1 ;
}
current _block _type _index = select _block _type ( ctx , - 1 ) ;
if _block1 = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
return {
c ( ) {
div = element ( "div" ) ;
if ( if _block0 )
if _block0 . c ( ) ;
t = space ( ) ;
if _block1 . c ( ) ;
attr ( div , "class" , "podcast-grid svelte-1xbcyvn" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
if ( if _block0 )
if _block0 . m ( div , null ) ;
append ( div , t ) ;
if _blocks [ current _block _type _index ] . m ( div , null ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
if ( ctx2 [ 1 ] . length > 0 ) {
if ( if _block0 ) {
if _block0 . p ( ctx2 , dirty ) ;
if ( dirty & 2 ) {
transition _in ( if _block0 , 1 ) ;
}
} else {
if _block0 = create _if _block _12 ( ctx2 ) ;
if _block0 . c ( ) ;
transition _in ( if _block0 , 1 ) ;
if _block0 . m ( div , t ) ;
}
} else if ( if _block0 ) {
group _outros ( ) ;
transition _out ( if _block0 , 1 , 1 , ( ) => {
if _block0 = null ;
} ) ;
check _outros ( ) ;
}
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type ( ctx2 , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if _blocks [ current _block _type _index ] . p ( ctx2 , dirty ) ;
} else {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
if _block1 = if _blocks [ current _block _type _index ] ;
if ( ! if _block1 ) {
if _block1 = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx2 ) ;
if _block1 . c ( ) ;
} else {
if _block1 . p ( ctx2 , dirty ) ;
}
transition _in ( if _block1 , 1 ) ;
if _block1 . m ( div , null ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block0 ) ;
transition _in ( if _block1 ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block0 ) ;
transition _out ( if _block1 ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
if ( if _block0 )
if _block0 . d ( ) ;
if _blocks [ current _block _type _index ] . d ( ) ;
}
} ;
}
function instance12 ( $$self , $$props , $$invalidate ) {
let { feeds = [ ] } = $$props ;
let { playlists : playlists2 = [ ] } = $$props ;
const dispatch = createEventDispatcher ( ) ;
function forwardClickPlaylist ( { detail : { playlist , event } } ) {
dispatch ( "clickPlaylist" , { playlist , event } ) ;
}
function clickPodcast _handler ( event ) {
bubble . call ( this , $$self , event ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "feeds" in $$props2 )
$$invalidate ( 0 , feeds = $$props2 . feeds ) ;
if ( "playlists" in $$props2 )
$$invalidate ( 1 , playlists2 = $$props2 . playlists ) ;
} ;
return [ feeds , playlists2 , forwardClickPlaylist , clickPodcast _handler ] ;
}
var PodcastGrid = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance12 , create _fragment12 , safe _not _equal , { feeds : 0 , playlists : 1 } , add _css9 ) ;
}
} ;
var PodcastGrid _default = PodcastGrid ;
// src/ui/obsidian/Slider.svelte
var import _obsidian12 = require ( "obsidian" ) ;
function create _fragment13 ( ctx ) {
let span ;
return {
c ( ) {
span = element ( "span" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
ctx [ 4 ] ( span ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
ctx [ 4 ] ( null ) ;
}
} ;
}
function instance13 ( $$self , $$props , $$invalidate ) {
let { value } = $$props ;
let { limits } = $$props ;
let sliderRef ;
const dispatch = createEventDispatcher ( ) ;
let slider ;
let { style : styles } = $$props ;
onMount ( ( ) => {
slider = new import _obsidian12 . SliderComponent ( sliderRef ) ;
updateSliderAttributes ( slider ) ;
} ) ;
afterUpdate ( ( ) => {
updateSliderAttributes ( slider ) ;
} ) ;
function updateSliderAttributes ( sldr ) {
if ( value )
sldr . setValue ( value ) ;
if ( limits )
sldr . setLimits . apply ( sldr , limits ) ;
if ( styles ) {
sldr . sliderEl . setAttr ( "style" , extractStylesFromObj ( styles ) ) ;
}
sldr . onChange ( ( value2 ) => {
dispatch ( "change" , { value : value2 } ) ;
} ) ;
}
function span _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
sliderRef = $$value ;
$$invalidate ( 0 , sliderRef ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "value" in $$props2 )
$$invalidate ( 1 , value = $$props2 . value ) ;
if ( "limits" in $$props2 )
$$invalidate ( 2 , limits = $$props2 . limits ) ;
if ( "style" in $$props2 )
$$invalidate ( 3 , styles = $$props2 . style ) ;
} ;
return [ sliderRef , value , limits , styles , span _binding ] ;
}
var Slider = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance13 , create _fragment13 , safe _not _equal , { value : 1 , limits : 2 , style : 3 } ) ;
}
} ;
var Slider _default = Slider ;
// src/ui/PodcastView/Loading.svelte
function add _css10 ( target ) {
append _styles ( target , "svelte-11b4xh2" , ".la-line-scale.svelte-11b4xh2.svelte-11b4xh2,.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2{position:relative;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.la-line-scale.svelte-11b4xh2.svelte-11b4xh2{display:block;font-size:0;color:#fff}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2{display:inline-block;float:none;background-color:currentColor;border:0 solid currentColor}.la-line-scale.svelte-11b4xh2.svelte-11b4xh2{width:40px;height:32px}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2{width:4px;height:32px;margin:2px;margin-top:0;margin-bottom:0;border-radius:0;-webkit-animation:svelte-11b4xh2-line-scale 1.2s infinite ease;-moz-animation:svelte-11b4xh2-line-scale 1.2s infinite ease;-o-animation:svelte-11b4xh2-line-scale 1.2s infinite ease;animation:svelte-11b4xh2-line-scale 1.2s infinite ease}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2:nth-child(1){-webkit-animation-delay:-1.2s;-moz-animation-delay:-1.2s;-o-animation-delay:-1.2s;animation-delay:-1.2s}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2:nth-child(2){-webkit-animation-delay:-1.1s;-moz-animation-delay:-1.1s;-o-animation-delay:-1.1s;animation-delay:-1.1s}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2:nth-child(3){-webkit-animation-delay:-1s;-moz-animation-delay:-1s;-o-animation-delay:-1s;animation-delay:-1s}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2:nth-child(4){-webkit-animation-delay:-.9s;-moz-animation-delay:-.9s;-o-animation-delay:-.9s;animation-delay:-.9s}.la-line-scale.svelte-11b4xh2>div.svelte-11b4xh2:nth-child(5){-webkit-animation-delay:-.8s;-moz-animation-delay:-.8s;-o-animation-delay:-.8s;animation-delay:-.8s}@-webkit-keyframes svelte-11b4xh2-line-scale{0%,40%,100%{-webkit-transform:scaleY(.4);transform:scaleY(.4)}20%{-webkit-transform:scaleY(1);transform:scaleY(1)}}@-moz-keyframes svelte-11b4xh2-line-scale{0%,40%,100%{-webkit-transform:scaleY(.4);-moz-transform:scaleY(.4);transform:scaleY(.4)}20%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);transform:scaleY(1)}}@-o-keyframes svelte-11b4xh2-line-scale{0%,40%,100%{-webkit-transform:scaleY(.4);-o-transform:scaleY(.4);transform:scaleY(.4)}20%{-webkit-transform:scaleY(1);-o-transform:scaleY(1);transform:scaleY(1)}}@keyframes svelte-11b4xh2-line-scale{0%,40%,100%{-webkit-transform:scaleY(.4);-moz-transform:scaleY(.4);-o-transform:scaleY(.4);transform:scaleY(.4)}20%{-webkit-transform:scaleY(1);-moz-transform:scaleY(1);-o-transform:scaleY(1);transform:scaleY(1)}}" ) ;
}
function create _fragment14 ( ctx ) {
let div5 ;
return {
c ( ) {
div5 = element ( "div" ) ;
div5 . innerHTML = ` <div class="svelte-11b4xh2"></div>
< div class = "svelte-11b4xh2" > < / d i v >
< div class = "svelte-11b4xh2" > < / d i v >
< div class = "svelte-11b4xh2" > < / d i v >
< div class = "svelte-11b4xh2" > < / d i v > ` ;
attr ( div5 , "class" , "la-line-scale svelte-11b4xh2" ) ;
} ,
m ( target , anchor ) {
insert ( target , div5 , anchor ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div5 ) ;
}
} ;
}
var Loading = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , null , create _fragment14 , safe _not _equal , { } , add _css10 ) ;
}
} ;
var Loading _default = Loading ;
// src/ui/common/IntersectionObserver.svelte
function add _css11 ( target ) {
append _styles ( target , "svelte-1kuj9kb" , "div.svelte-1kuj9kb{width:100%;height:100%}" ) ;
}
var get _default _slot _changes = ( dirty ) => ( { intersecting : dirty & 1 } ) ;
var get _default _slot _context = ( ctx ) => ( { intersecting : ctx [ 0 ] } ) ;
function create _fragment15 ( ctx ) {
let div ;
let current ;
const default _slot _template = ctx [ 8 ] . default ;
const default _slot = create _slot ( default _slot _template , ctx , ctx [ 7 ] , get _default _slot _context ) ;
return {
c ( ) {
div = element ( "div" ) ;
if ( default _slot )
default _slot . c ( ) ;
attr ( div , "class" , "svelte-1kuj9kb" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
if ( default _slot ) {
default _slot . m ( div , null ) ;
}
ctx [ 9 ] ( div ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
if ( default _slot ) {
if ( default _slot . p && ( ! current || dirty & 129 ) ) {
update _slot _base ( default _slot , default _slot _template , ctx2 , ctx2 [ 7 ] , ! current ? get _all _dirty _from _scope ( ctx2 [ 7 ] ) : get _slot _changes ( default _slot _template , ctx2 [ 7 ] , dirty , get _default _slot _changes ) , get _default _slot _context ) ;
}
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( default _slot , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( default _slot , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
if ( default _slot )
default _slot . d ( detaching ) ;
ctx [ 9 ] ( null ) ;
}
} ;
}
function instance14 ( $$self , $$props , $$invalidate ) {
let { $$slots : slots = { } , $$scope } = $$props ;
let { once = false } = $$props ;
let { top = 0 } = $$props ;
let { bottom = 0 } = $$props ;
let { left = 0 } = $$props ;
let { right = 0 } = $$props ;
let intersecting = false ;
let container ;
onMount ( ( ) => {
if ( typeof IntersectionObserver !== "undefined" ) {
const rootMargin = ` ${ bottom } px ${ left } px ${ top } px ${ right } px ` ;
const observer = new IntersectionObserver ( ( entries ) => {
$$invalidate ( 0 , intersecting = entries [ 0 ] . isIntersecting ) ;
if ( intersecting && once ) {
observer . unobserve ( container ) ;
}
} , { rootMargin } ) ;
observer . observe ( container ) ;
return ( ) => observer . unobserve ( container ) ;
}
function handler ( ) {
const bcr = container . getBoundingClientRect ( ) ;
$$invalidate ( 0 , intersecting = bcr . bottom + bottom > 0 && bcr . right + right > 0 && bcr . top - top < window . innerHeight && bcr . left - left < window . innerWidth ) ;
if ( intersecting && once ) {
window . removeEventListener ( "scroll" , handler ) ;
}
}
window . addEventListener ( "scroll" , handler ) ;
return ( ) => window . removeEventListener ( "scroll" , handler ) ;
} ) ;
function div _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
container = $$value ;
$$invalidate ( 1 , container ) ;
} ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "once" in $$props2 )
$$invalidate ( 2 , once = $$props2 . once ) ;
if ( "top" in $$props2 )
$$invalidate ( 3 , top = $$props2 . top ) ;
if ( "bottom" in $$props2 )
$$invalidate ( 4 , bottom = $$props2 . bottom ) ;
if ( "left" in $$props2 )
$$invalidate ( 5 , left = $$props2 . left ) ;
if ( "right" in $$props2 )
$$invalidate ( 6 , right = $$props2 . right ) ;
if ( "$$scope" in $$props2 )
$$invalidate ( 7 , $$scope = $$props2 . $$scope ) ;
} ;
return [
intersecting ,
container ,
once ,
top ,
bottom ,
left ,
right ,
$$scope ,
slots ,
div _binding
] ;
}
var IntersectionObserver _1 = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance14 , create _fragment15 , safe _not _equal , {
once : 2 ,
top : 3 ,
bottom : 4 ,
left : 5 ,
right : 6
} , add _css11 ) ;
}
} ;
var IntersectionObserver _default = IntersectionObserver _1 ;
// src/ui/common/ImageLoader.svelte
function create _if _block4 ( ctx ) {
let image ;
let current ;
image = new Image _default ( {
props : {
alt : ctx [ 1 ] ,
src : ctx [ 0 ] ,
fadeIn : ctx [ 2 ] ,
class : ctx [ 3 ]
}
} ) ;
image . $on ( "click" , ctx [ 5 ] ) ;
return {
c ( ) {
create _component ( image . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( image , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const image _changes = { } ;
if ( dirty & 2 )
image _changes . alt = ctx2 [ 1 ] ;
if ( dirty & 1 )
image _changes . src = ctx2 [ 0 ] ;
if ( dirty & 4 )
image _changes . fadeIn = ctx2 [ 2 ] ;
if ( dirty & 8 )
image _changes . class = ctx2 [ 3 ] ;
image . $set ( image _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( image . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( image . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( image , detaching ) ;
}
} ;
}
function create _default _slot ( ctx ) {
let if _block _anchor ;
let current ;
let if _block = ctx [ 6 ] && create _if _block4 ( ctx ) ;
return {
c ( ) {
if ( if _block )
if _block . c ( ) ;
if _block _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
if ( if _block )
if _block . m ( target , anchor ) ;
insert ( target , if _block _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( ctx2 [ 6 ] ) {
if ( if _block ) {
if _block . p ( ctx2 , dirty ) ;
if ( dirty & 64 ) {
transition _in ( if _block , 1 ) ;
}
} else {
if _block = create _if _block4 ( ctx2 ) ;
if _block . c ( ) ;
transition _in ( if _block , 1 ) ;
if _block . m ( if _block _anchor . parentNode , if _block _anchor ) ;
}
} else if ( if _block ) {
group _outros ( ) ;
transition _out ( if _block , 1 , 1 , ( ) => {
if _block = null ;
} ) ;
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( if _block )
if _block . d ( detaching ) ;
if ( detaching )
detach ( if _block _anchor ) ;
}
} ;
}
function create _fragment16 ( ctx ) {
let intersectionobserver ;
let current ;
intersectionobserver = new IntersectionObserver _default ( {
props : {
once : true ,
$$slots : {
default : [
create _default _slot ,
( { intersecting } ) => ( { 6 : intersecting } ) ,
( { intersecting } ) => intersecting ? 64 : 0
]
} ,
$$scope : { ctx }
}
} ) ;
return {
c ( ) {
create _component ( intersectionobserver . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( intersectionobserver , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
const intersectionobserver _changes = { } ;
if ( dirty & 207 ) {
intersectionobserver _changes . $$scope = { dirty , ctx : ctx2 } ;
}
intersectionobserver . $set ( intersectionobserver _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( intersectionobserver . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( intersectionobserver . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( intersectionobserver , detaching ) ;
}
} ;
}
function instance15 ( $$self , $$props , $$invalidate ) {
let { src } = $$props ;
let { alt } = $$props ;
let { fadeIn = false } = $$props ;
let { class : _class = "" } = $$props ;
const dispatcher = createEventDispatcher ( ) ;
const click _handler = ( event ) => dispatcher ( "click" , { event } ) ;
$$self . $$set = ( $$props2 ) => {
if ( "src" in $$props2 )
$$invalidate ( 0 , src = $$props2 . src ) ;
if ( "alt" in $$props2 )
$$invalidate ( 1 , alt = $$props2 . alt ) ;
if ( "fadeIn" in $$props2 )
$$invalidate ( 2 , fadeIn = $$props2 . fadeIn ) ;
if ( "class" in $$props2 )
$$invalidate ( 3 , _class = $$props2 . class ) ;
} ;
return [ src , alt , fadeIn , _class , dispatcher , click _handler ] ;
}
var ImageLoader = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance15 , create _fragment16 , safe _not _equal , { src : 0 , alt : 1 , fadeIn : 2 , class : 3 } ) ;
}
} ;
var ImageLoader _default = ImageLoader ;
// src/ui/PodcastView/EpisodeListItem.svelte
function add _css12 ( target ) {
append _styles ( target , "svelte-1gcgk6w" , ".podcast-episode-item.svelte-1gcgk6w{display:flex;flex-direction:row;justify-content:space-between;align-items:center;padding:0.5rem;width:100%;border:solid 1px var(--background-divider);gap:0.25rem}.podcast-episode-item.svelte-1gcgk6w:hover{background-color:var(--background-divider)}.podcast-episode-item.svelte-1gcgk6w:hover{cursor:pointer}.strikeout.svelte-1gcgk6w{text-decoration:line-through}.podcast-episode-information.svelte-1gcgk6w{display:flex;flex-direction:column;justify-content:space-between;align-items:left;width:100%}.episode-item-date.svelte-1gcgk6w{color:gray}.podcast-episode-thumbnail-container.svelte-1gcgk6w{flex-basis:20%;display:flex;align-items:center;justify-content:center}.podcast-episode-thumbnail{border-radius:15%;max-width:5rem;max-height:5rem;cursor:pointer !important}" ) ;
}
function create _if _block _13 ( ctx ) {
let div ;
return {
c ( ) {
div = element ( "div" ) ;
attr ( div , "class" , "podcast-episode-thumbnail-container svelte-1gcgk6w" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
} ,
p : noop ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
}
} ;
}
function create _if _block5 ( ctx ) {
let div ;
let imageloader ;
let current ;
imageloader = new ImageLoader _default ( {
props : {
src : ctx [ 0 ] . artworkUrl ,
alt : ctx [ 0 ] . title ,
fadeIn : true ,
class : "podcast-episode-thumbnail"
}
} ) ;
return {
c ( ) {
div = element ( "div" ) ;
create _component ( imageloader . $$ . fragment ) ;
attr ( div , "class" , "podcast-episode-thumbnail-container svelte-1gcgk6w" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( imageloader , div , null ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const imageloader _changes = { } ;
if ( dirty & 1 )
imageloader _changes . src = ctx2 [ 0 ] . artworkUrl ;
if ( dirty & 1 )
imageloader _changes . alt = ctx2 [ 0 ] . title ;
imageloader . $set ( imageloader _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( imageloader . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( imageloader . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( imageloader ) ;
}
} ;
}
function create _fragment17 ( ctx ) {
let div1 ;
let current _block _type _index ;
let if _block ;
let t0 ;
let div0 ;
let span0 ;
let t1 _value = ctx [ 3 ] . toUpperCase ( ) + "" ;
let t1 ;
let t2 ;
let span1 ;
let t3 _value = ctx [ 0 ] . title + "" ;
let t3 ;
let span1 _class _value ;
let current ;
let mounted ;
let dispose ;
const if _block _creators = [ create _if _block5 , create _if _block _13 ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx2 , dirty ) {
var _a ;
if ( ctx2 [ 2 ] && ( ( _a = ctx2 [ 0 ] ) == null ? void 0 : _a . artworkUrl ) )
return 0 ;
if ( ctx2 [ 2 ] )
return 1 ;
return - 1 ;
}
if ( ~ ( current _block _type _index = select _block _type ( ctx , - 1 ) ) ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
}
return {
c ( ) {
div1 = element ( "div" ) ;
if ( if _block )
if _block . c ( ) ;
t0 = space ( ) ;
div0 = element ( "div" ) ;
span0 = element ( "span" ) ;
t1 = text ( t1 _value ) ;
t2 = space ( ) ;
span1 = element ( "span" ) ;
t3 = text ( t3 _value ) ;
attr ( span0 , "class" , "episode-item-date svelte-1gcgk6w" ) ;
attr ( span1 , "class" , span1 _class _value = null _to _empty ( ` episode-item-title ${ ctx [ 1 ] && "strikeout" } ` ) + " svelte-1gcgk6w" ) ;
attr ( div0 , "class" , "podcast-episode-information svelte-1gcgk6w" ) ;
set _style ( div0 , "flex-basis" , "80%" , false ) ;
attr ( div1 , "class" , "podcast-episode-item svelte-1gcgk6w" ) ;
} ,
m ( target , anchor ) {
insert ( target , div1 , anchor ) ;
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . m ( div1 , null ) ;
}
append ( div1 , t0 ) ;
append ( div1 , div0 ) ;
append ( div0 , span0 ) ;
append ( span0 , t1 ) ;
append ( div0 , t2 ) ;
append ( div0 , span1 ) ;
append ( span1 , t3 ) ;
current = true ;
if ( ! mounted ) {
dispose = [
listen ( div1 , "click" , ctx [ 4 ] ) ,
listen ( div1 , "contextmenu" , ctx [ 5 ] )
] ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type ( ctx2 , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . p ( ctx2 , dirty ) ;
}
} else {
if ( if _block ) {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
}
if ( ~ current _block _type _index ) {
if _block = if _blocks [ current _block _type _index ] ;
if ( ! if _block ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx2 ) ;
if _block . c ( ) ;
} else {
if _block . p ( ctx2 , dirty ) ;
}
transition _in ( if _block , 1 ) ;
if _block . m ( div1 , t0 ) ;
} else {
if _block = null ;
}
}
if ( ( ! current || dirty & 8 ) && t1 _value !== ( t1 _value = ctx2 [ 3 ] . toUpperCase ( ) + "" ) )
set _data ( t1 , t1 _value ) ;
if ( ( ! current || dirty & 1 ) && t3 _value !== ( t3 _value = ctx2 [ 0 ] . title + "" ) )
set _data ( t3 , t3 _value ) ;
if ( ! current || dirty & 2 && span1 _class _value !== ( span1 _class _value = null _to _empty ( ` episode-item-title ${ ctx2 [ 1 ] && "strikeout" } ` ) + " svelte-1gcgk6w" ) ) {
attr ( span1 , "class" , span1 _class _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div1 ) ;
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . d ( ) ;
}
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function instance16 ( $$self , $$props , $$invalidate ) {
let { episode } = $$props ;
let { episodeFinished = false } = $$props ;
let { showEpisodeImage = false } = $$props ;
const dispatch = createEventDispatcher ( ) ;
function onClickEpisode ( ) {
dispatch ( "clickEpisode" , { episode } ) ;
}
function onContextMenu ( event ) {
dispatch ( "contextMenu" , { episode , event } ) ;
}
let _date ;
let date ;
$$self . $$set = ( $$props2 ) => {
if ( "episode" in $$props2 )
$$invalidate ( 0 , episode = $$props2 . episode ) ;
if ( "episodeFinished" in $$props2 )
$$invalidate ( 1 , episodeFinished = $$props2 . episodeFinished ) ;
if ( "showEpisodeImage" in $$props2 )
$$invalidate ( 2 , showEpisodeImage = $$props2 . showEpisodeImage ) ;
} ;
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty & 65 ) {
$ : {
$$invalidate ( 6 , _date = new Date ( episode . episodeDate || "" ) ) ;
$$invalidate ( 3 , date = window . moment ( _date ) . format ( "DD MMMM YYYY" ) ) ;
}
}
} ;
return [
episode ,
episodeFinished ,
showEpisodeImage ,
date ,
onClickEpisode ,
onContextMenu ,
_date
] ;
}
var EpisodeListItem = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance16 , create _fragment17 , safe _not _equal , {
episode : 0 ,
episodeFinished : 1 ,
showEpisodeImage : 2
} , add _css12 ) ;
}
} ;
var EpisodeListItem _default = EpisodeListItem ;
// src/ui/PodcastView/EpisodeList.svelte
function add _css13 ( target ) {
append _styles ( target , "svelte-1ov6u04" , ".episode-list-view-container.svelte-1ov6u04{display:flex;flex-direction:column;align-items:center;justify-content:center}.podcast-episode-list.svelte-1ov6u04{display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;height:100%}.episode-list-menu.svelte-1ov6u04{display:flex;flex-direction:row;justify-content:right;align-items:center;gap:1rem;width:100%;padding-left:0.5rem;padding-right:0.5rem}.episode-list-search.svelte-1ov6u04{width:100%;margin-bottom:0.5rem}" ) ;
}
function get _each _context4 ( ctx , list , i ) {
var _a ;
const child _ctx = ctx . slice ( ) ;
child _ctx [ 15 ] = list [ i ] ;
const constants _0 = ( _a = child _ctx [ 5 ] [ child _ctx [ 15 ] . title ] ) == null ? void 0 : _a . finished ;
child _ctx [ 16 ] = constants _0 ;
return child _ctx ;
}
var get _header _slot _changes = ( dirty ) => ( { } ) ;
var get _header _slot _context = ( ctx ) => ( { } ) ;
function fallback _block ( ctx ) {
let t ;
return {
c ( ) {
t = text ( "Fallback" ) ;
} ,
m ( target , anchor ) {
insert ( target , t , anchor ) ;
} ,
d ( detaching ) {
if ( detaching )
detach ( t ) ;
}
} ;
}
function create _if _block _2 ( ctx ) {
let div1 ;
let div0 ;
let text _1 ;
let updating _value ;
let t0 ;
let icon0 ;
let t1 ;
let icon1 ;
let current ;
function text _1 _value _binding ( value ) {
ctx [ 12 ] ( value ) ;
}
let text _1 _props = {
placeholder : "Search episodes" ,
style : { width : "100%" }
} ;
if ( ctx [ 4 ] !== void 0 ) {
text _1 _props . value = ctx [ 4 ] ;
}
text _1 = new Text _default ( { props : text _1 _props } ) ;
binding _callbacks . push ( ( ) => bind ( text _1 , "value" , text _1 _value _binding ) ) ;
text _1 . $on ( "change" , ctx [ 9 ] ) ;
icon0 = new Icon _default ( {
props : {
icon : ctx [ 3 ] ? "eye-off" : "eye" ,
size : 25
}
} ) ;
icon0 . $on ( "click" , ctx [ 13 ] ) ;
icon1 = new Icon _default ( { props : { icon : "refresh-cw" , size : 25 } } ) ;
icon1 . $on ( "click" , ctx [ 14 ] ) ;
return {
c ( ) {
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( text _1 . $$ . fragment ) ;
t0 = space ( ) ;
create _component ( icon0 . $$ . fragment ) ;
t1 = space ( ) ;
create _component ( icon1 . $$ . fragment ) ;
attr ( div0 , "class" , "episode-list-search svelte-1ov6u04" ) ;
attr ( div1 , "class" , "episode-list-menu svelte-1ov6u04" ) ;
} ,
m ( target , anchor ) {
insert ( target , div1 , anchor ) ;
append ( div1 , div0 ) ;
mount _component ( text _1 , div0 , null ) ;
append ( div1 , t0 ) ;
mount _component ( icon0 , div1 , null ) ;
append ( div1 , t1 ) ;
mount _component ( icon1 , div1 , null ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const text _1 _changes = { } ;
if ( ! updating _value && dirty & 16 ) {
updating _value = true ;
text _1 _changes . value = ctx2 [ 4 ] ;
add _flush _callback ( ( ) => updating _value = false ) ;
}
text _1 . $set ( text _1 _changes ) ;
const icon0 _changes = { } ;
if ( dirty & 8 )
icon0 _changes . icon = ctx2 [ 3 ] ? "eye-off" : "eye" ;
icon0 . $set ( icon0 _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( text _1 . $$ . fragment , local ) ;
transition _in ( icon0 . $$ . fragment , local ) ;
transition _in ( icon1 . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( text _1 . $$ . fragment , local ) ;
transition _out ( icon0 . $$ . fragment , local ) ;
transition _out ( icon1 . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div1 ) ;
destroy _component ( text _1 ) ;
destroy _component ( icon0 ) ;
destroy _component ( icon1 ) ;
}
} ;
}
function create _if _block _14 ( ctx ) {
let p ;
return {
c ( ) {
p = element ( "p" ) ;
p . textContent = "No episodes found." ;
} ,
m ( target , anchor ) {
insert ( target , p , anchor ) ;
} ,
d ( detaching ) {
if ( detaching )
detach ( p ) ;
}
} ;
}
function create _if _block6 ( ctx ) {
let episodelistitem ;
let current ;
episodelistitem = new EpisodeListItem _default ( {
props : {
episode : ctx [ 15 ] ,
episodeFinished : ctx [ 16 ] ,
showEpisodeImage : ctx [ 1 ]
}
} ) ;
episodelistitem . $on ( "clickEpisode" , ctx [ 7 ] ) ;
episodelistitem . $on ( "contextMenu" , ctx [ 8 ] ) ;
return {
c ( ) {
create _component ( episodelistitem . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( episodelistitem , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const episodelistitem _changes = { } ;
if ( dirty & 1 )
episodelistitem _changes . episode = ctx2 [ 15 ] ;
if ( dirty & 33 )
episodelistitem _changes . episodeFinished = ctx2 [ 16 ] ;
if ( dirty & 2 )
episodelistitem _changes . showEpisodeImage = ctx2 [ 1 ] ;
episodelistitem . $set ( episodelistitem _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( episodelistitem . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( episodelistitem . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( episodelistitem , detaching ) ;
}
} ;
}
function create _each _block4 ( ctx ) {
let if _block _anchor ;
let current ;
let if _block = ( ! ctx [ 3 ] || ! ctx [ 16 ] ) && create _if _block6 ( ctx ) ;
return {
c ( ) {
if ( if _block )
if _block . c ( ) ;
if _block _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
if ( if _block )
if _block . m ( target , anchor ) ;
insert ( target , if _block _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( ! ctx2 [ 3 ] || ! ctx2 [ 16 ] ) {
if ( if _block ) {
if _block . p ( ctx2 , dirty ) ;
if ( dirty & 41 ) {
transition _in ( if _block , 1 ) ;
}
} else {
if _block = create _if _block6 ( ctx2 ) ;
if _block . c ( ) ;
transition _in ( if _block , 1 ) ;
if _block . m ( if _block _anchor . parentNode , if _block _anchor ) ;
}
} else if ( if _block ) {
group _outros ( ) ;
transition _out ( if _block , 1 , 1 , ( ) => {
if _block = null ;
} ) ;
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( if _block )
if _block . d ( detaching ) ;
if ( detaching )
detach ( if _block _anchor ) ;
}
} ;
}
function create _fragment18 ( ctx ) {
let div1 ;
let t0 ;
let t1 ;
let div0 ;
let t2 ;
let current ;
const header _slot _template = ctx [ 11 ] . header ;
const header _slot = create _slot ( header _slot _template , ctx , ctx [ 10 ] , get _header _slot _context ) ;
const header _slot _or _fallback = header _slot || fallback _block ( ctx ) ;
let if _block0 = ctx [ 2 ] && create _if _block _2 ( ctx ) ;
let if _block1 = ctx [ 0 ] . length === 0 && create _if _block _14 ( ctx ) ;
let each _value = ctx [ 0 ] ;
let each _blocks = [ ] ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
each _blocks [ i ] = create _each _block4 ( get _each _context4 ( ctx , each _value , i ) ) ;
}
const out = ( i ) => transition _out ( each _blocks [ i ] , 1 , 1 , ( ) => {
each _blocks [ i ] = null ;
} ) ;
return {
c ( ) {
div1 = element ( "div" ) ;
if ( header _slot _or _fallback )
header _slot _or _fallback . c ( ) ;
t0 = space ( ) ;
if ( if _block0 )
if _block0 . c ( ) ;
t1 = space ( ) ;
div0 = element ( "div" ) ;
if ( if _block1 )
if _block1 . c ( ) ;
t2 = space ( ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . c ( ) ;
}
attr ( div0 , "class" , "podcast-episode-list svelte-1ov6u04" ) ;
attr ( div1 , "class" , "episode-list-view-container svelte-1ov6u04" ) ;
} ,
m ( target , anchor ) {
insert ( target , div1 , anchor ) ;
if ( header _slot _or _fallback ) {
header _slot _or _fallback . m ( div1 , null ) ;
}
append ( div1 , t0 ) ;
if ( if _block0 )
if _block0 . m ( div1 , null ) ;
append ( div1 , t1 ) ;
append ( div1 , div0 ) ;
if ( if _block1 )
if _block1 . m ( div0 , null ) ;
append ( div0 , t2 ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
each _blocks [ i ] . m ( div0 , null ) ;
}
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
if ( header _slot ) {
if ( header _slot . p && ( ! current || dirty & 1024 ) ) {
update _slot _base ( header _slot , header _slot _template , ctx2 , ctx2 [ 10 ] , ! current ? get _all _dirty _from _scope ( ctx2 [ 10 ] ) : get _slot _changes ( header _slot _template , ctx2 [ 10 ] , dirty , get _header _slot _changes ) , get _header _slot _context ) ;
}
}
if ( ctx2 [ 2 ] ) {
if ( if _block0 ) {
if _block0 . p ( ctx2 , dirty ) ;
if ( dirty & 4 ) {
transition _in ( if _block0 , 1 ) ;
}
} else {
if _block0 = create _if _block _2 ( ctx2 ) ;
if _block0 . c ( ) ;
transition _in ( if _block0 , 1 ) ;
if _block0 . m ( div1 , t1 ) ;
}
} else if ( if _block0 ) {
group _outros ( ) ;
transition _out ( if _block0 , 1 , 1 , ( ) => {
if _block0 = null ;
} ) ;
check _outros ( ) ;
}
if ( ctx2 [ 0 ] . length === 0 ) {
if ( if _block1 ) {
} else {
if _block1 = create _if _block _14 ( ctx2 ) ;
if _block1 . c ( ) ;
if _block1 . m ( div0 , t2 ) ;
}
} else if ( if _block1 ) {
if _block1 . d ( 1 ) ;
if _block1 = null ;
}
if ( dirty & 427 ) {
each _value = ctx2 [ 0 ] ;
let i ;
for ( i = 0 ; i < each _value . length ; i += 1 ) {
const child _ctx = get _each _context4 ( ctx2 , each _value , i ) ;
if ( each _blocks [ i ] ) {
each _blocks [ i ] . p ( child _ctx , dirty ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
} else {
each _blocks [ i ] = create _each _block4 ( child _ctx ) ;
each _blocks [ i ] . c ( ) ;
transition _in ( each _blocks [ i ] , 1 ) ;
each _blocks [ i ] . m ( div0 , null ) ;
}
}
group _outros ( ) ;
for ( i = each _value . length ; i < each _blocks . length ; i += 1 ) {
out ( i ) ;
}
check _outros ( ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( header _slot _or _fallback , local ) ;
transition _in ( if _block0 ) ;
for ( let i = 0 ; i < each _value . length ; i += 1 ) {
transition _in ( each _blocks [ i ] ) ;
}
current = true ;
} ,
o ( local ) {
transition _out ( header _slot _or _fallback , local ) ;
transition _out ( if _block0 ) ;
each _blocks = each _blocks . filter ( Boolean ) ;
for ( let i = 0 ; i < each _blocks . length ; i += 1 ) {
transition _out ( each _blocks [ i ] ) ;
}
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div1 ) ;
if ( header _slot _or _fallback )
header _slot _or _fallback . d ( detaching ) ;
if ( if _block0 )
if _block0 . d ( ) ;
if ( if _block1 )
if _block1 . d ( ) ;
destroy _each ( each _blocks , detaching ) ;
}
} ;
}
function instance17 ( $$self , $$props , $$invalidate ) {
let $playedEpisodes ;
component _subscribe ( $$self , playedEpisodes , ( $$value ) => $$invalidate ( 5 , $playedEpisodes = $$value ) ) ;
let { $$slots : slots = { } , $$scope } = $$props ;
let { episodes = [ ] } = $$props ;
let { showThumbnails = false } = $$props ;
let { showListMenu = true } = $$props ;
let hidePlayedEpisodes = false ;
let searchInputQuery = "" ;
const dispatch = createEventDispatcher ( ) ;
function forwardClickEpisode ( event ) {
dispatch ( "clickEpisode" , { episode : event . detail . episode } ) ;
}
function forwardContextMenuEpisode ( event ) {
dispatch ( "contextMenuEpisode" , {
episode : event . detail . episode ,
event : event . detail . event
} ) ;
}
function forwardSearchInput ( event ) {
dispatch ( "search" , { query : event . detail . value } ) ;
}
function text _1 _value _binding ( value ) {
searchInputQuery = value ;
$$invalidate ( 4 , searchInputQuery ) ;
}
const click _handler = ( ) => $$invalidate ( 3 , hidePlayedEpisodes = ! hidePlayedEpisodes ) ;
const click _handler _1 = ( ) => dispatch ( "clickRefresh" ) ;
$$self . $$set = ( $$props2 ) => {
if ( "episodes" in $$props2 )
$$invalidate ( 0 , episodes = $$props2 . episodes ) ;
if ( "showThumbnails" in $$props2 )
$$invalidate ( 1 , showThumbnails = $$props2 . showThumbnails ) ;
if ( "showListMenu" in $$props2 )
$$invalidate ( 2 , showListMenu = $$props2 . showListMenu ) ;
if ( "$$scope" in $$props2 )
$$invalidate ( 10 , $$scope = $$props2 . $$scope ) ;
} ;
return [
episodes ,
showThumbnails ,
showListMenu ,
hidePlayedEpisodes ,
searchInputQuery ,
$playedEpisodes ,
dispatch ,
forwardClickEpisode ,
forwardContextMenuEpisode ,
forwardSearchInput ,
$$scope ,
slots ,
text _1 _value _binding ,
click _handler ,
click _handler _1
] ;
}
var EpisodeList = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance17 , create _fragment18 , safe _not _equal , {
episodes : 0 ,
showThumbnails : 1 ,
showListMenu : 2
} , add _css13 ) ;
}
} ;
var EpisodeList _default = EpisodeList ;
// src/ui/common/Progressbar.svelte
function create _fragment19 ( ctx ) {
let progress ;
let mounted ;
let dispose ;
return {
c ( ) {
progress = element ( "progress" ) ;
attr ( progress , "style" , ctx [ 2 ] ) ;
attr ( progress , "max" , ctx [ 0 ] ) ;
progress . value = ctx [ 1 ] ;
} ,
m ( target , anchor ) {
insert ( target , progress , anchor ) ;
if ( ! mounted ) {
dispose = [
listen ( progress , "click" , ctx [ 3 ] ) ,
listen ( progress , "mousedown" , ctx [ 4 ] ) ,
listen ( progress , "mouseup" , ctx [ 5 ] ) ,
listen ( progress , "mousemove" , ctx [ 6 ] )
] ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
if ( dirty & 4 ) {
attr ( progress , "style" , ctx2 [ 2 ] ) ;
}
if ( dirty & 1 ) {
attr ( progress , "max" , ctx2 [ 0 ] ) ;
}
if ( dirty & 2 ) {
progress . value = ctx2 [ 1 ] ;
}
} ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( progress ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function instance18 ( $$self , $$props , $$invalidate ) {
let { max } = $$props ;
let { value } = $$props ;
let isDragging = false ;
let { style : _styled = { } } = $$props ;
let styles ;
const dispatch = createEventDispatcher ( ) ;
function forwardClick ( e ) {
dispatch ( "click" , { event : e } ) ;
}
function onDragStart ( ) {
isDragging = true ;
}
function onDragEnd ( ) {
isDragging = false ;
}
function handleDragging ( e ) {
if ( ! isDragging )
return ;
forwardClick ( e ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "max" in $$props2 )
$$invalidate ( 0 , max = $$props2 . max ) ;
if ( "value" in $$props2 )
$$invalidate ( 1 , value = $$props2 . value ) ;
if ( "style" in $$props2 )
$$invalidate ( 7 , _styled = $$props2 . style ) ;
} ;
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty & 128 ) {
$ : {
$$invalidate ( 2 , styles = extractStylesFromObj ( _styled ) ) ;
}
}
} ;
return [
max ,
value ,
styles ,
forwardClick ,
onDragStart ,
onDragEnd ,
handleDragging ,
_styled
] ;
}
var Progressbar = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance18 , create _fragment19 , safe _not _equal , { max : 0 , value : 1 , style : 7 } ) ;
}
} ;
var Progressbar _default = Progressbar ;
// src/ui/PodcastView/spawnEpisodeContextMenu.ts
var import _obsidian15 = require ( "obsidian" ) ;
// src/createPodcastNote.ts
var import _obsidian13 = require ( "obsidian" ) ;
// src/utility/addExtension.ts
function addExtension ( path , extension ) {
const ext = extension . startsWith ( "." ) ? extension : ` . ${ extension } ` ;
return path . endsWith ( ext ) ? path : ` ${ path } ${ ext } ` ;
}
// src/createPodcastNote.ts
function createPodcastNote ( episode ) {
return _ _async ( this , null , function * ( ) {
const pluginInstance = get _store _value ( plugin ) ;
const filePath = FilePathTemplateEngine ( pluginInstance . settings . note . path , episode ) ;
const filePathDotMd = addExtension ( filePath , "md" ) ;
const content = NoteTemplateEngine ( pluginInstance . settings . note . template , episode ) ;
try {
const file = yield createFileIfNotExists ( filePathDotMd , content , episode ) ;
app . workspace . getLeaf ( ) . openFile ( file ) ;
} catch ( error ) {
console . error ( error ) ;
new import _obsidian13 . Notice ( ` Failed to create note: " ${ filePathDotMd } " ` ) ;
}
} ) ;
}
function getPodcastNote ( episode ) {
const pluginInstance = get _store _value ( plugin ) ;
const filePath = FilePathTemplateEngine ( pluginInstance . settings . note . path , episode ) ;
const filePathDotMd = addExtension ( filePath , "md" ) ;
const file = app . vault . getAbstractFileByPath ( filePathDotMd ) ;
if ( ! file || ! ( file instanceof import _obsidian13 . TFile ) ) {
return null ;
}
return file ;
}
function openPodcastNote ( epiosode ) {
const file = getPodcastNote ( epiosode ) ;
if ( ! file ) {
new import _obsidian13 . Notice ( ` Note for " ${ epiosode . title } " does not exist ` ) ;
return ;
}
app . workspace . getLeaf ( ) . openFile ( file ) ;
}
function createFileIfNotExists ( path , content , episode , createFolder = true ) {
return _ _async ( this , null , function * ( ) {
const file = getPodcastNote ( episode ) ;
if ( file ) {
new import _obsidian13 . Notice ( ` Note for " ${ episode . title } " already exists ` ) ;
return file ;
}
const foldersInPath = path . split ( "/" ) . slice ( 0 , - 1 ) ;
for ( let i = 0 ; i < foldersInPath . length ; i ++ ) {
const folderPath = foldersInPath . slice ( 0 , i + 1 ) . join ( "/" ) ;
const folder = app . vault . getAbstractFileByPath ( folderPath ) ;
if ( ! folder && createFolder ) {
yield app . vault . createFolder ( folderPath ) ;
}
}
return yield app . vault . create ( path , content ) ;
} ) ;
}
// src/downloadEpisode.ts
var import _obsidian14 = require ( "obsidian" ) ;
function downloadFile ( url , options ) {
return _ _async ( this , null , function * ( ) {
var _a , _b , _c , _d ;
try {
const response = yield ( 0 , import _obsidian14 . requestUrl ) ( { url , method : "GET" } ) ;
if ( response . status !== 200 ) {
throw new Error ( "Could not download episode." ) ;
}
const contentLength = response . arrayBuffer . byteLength ;
( _a = options == null ? void 0 : options . onFinished ) == null ? void 0 : _a . call ( options ) ;
return {
blob : new Blob ( [ response . arrayBuffer ] , {
type : ( _c = ( _b = response . headers [ "content-type" ] ) != null ? _b : response . headers [ "Content-Type" ] ) != null ? _c : ""
} ) ,
contentLength ,
receivedLength : contentLength ,
responseUrl : url
} ;
} catch ( error ) {
const err = new Error ( ` Failed to download ${ url } :
$ { error . message } ` );
( _d = options == null ? void 0 : options . onError ) == null ? void 0 : _d . call ( options , err ) ;
throw err ;
}
} ) ;
}
function downloadEpisodeWithNotice ( episode , downloadPathTemplate ) {
return _ _async ( this , null , function * ( ) {
const { doc , update : update2 } = createNoticeDoc ( ` Download " ${ episode . title } " ` ) ;
const SOME _LARGE _INT _SO _THE _BOX _DOESNT _AUTO _CLOSE = 999999999 ;
const notice = new import _obsidian14 . Notice ( doc , SOME _LARGE _INT _SO _THE _BOX _DOESNT _AUTO _CLOSE ) ;
update2 ( ( bodyEl ) => bodyEl . createEl ( "p" , { text : "Starting download..." } ) ) ;
update2 ( ( bodyEl ) => {
bodyEl . createEl ( "p" , { text : "Downloading..." } ) ;
} ) ;
const { blob , responseUrl } = yield downloadFile ( episode . streamUrl , {
onFinished : ( ) => {
update2 ( ( bodyEl ) => bodyEl . createEl ( "p" , { text : "Download complete!" } ) ) ;
} ,
onError : ( error ) => {
update2 ( ( bodyEl ) => bodyEl . createEl ( "p" , { text : ` Download failed: ${ error . message } ` } ) ) ;
}
} ) ;
if ( ! blob . type . contains ( "audio" ) ) {
update2 ( ( bodyEl ) => {
bodyEl . createEl ( "p" , {
text : ` Downloaded file is not an audio file. It is of type " ${ blob . type } ". Blob: ${ blob . size } bytes. `
} ) ;
} ) ;
throw new Error ( "Not an audio file" ) ;
}
try {
update2 ( ( bodyEl ) => bodyEl . createEl ( "p" , { text : ` Creating file... ` } ) ) ;
yield createEpisodeFile ( {
episode ,
downloadPathTemplate ,
blob ,
responseUrl
} ) ;
update2 ( ( bodyEl ) => bodyEl . createEl ( "p" , {
text : ` Successfully downloaded " ${ episode . title } " from ${ episode . podcastName } . `
} ) ) ;
} catch ( error ) {
update2 ( ( bodyEl ) => {
bodyEl . createEl ( "p" , {
text : ` Failed to create file for downloaded episode " ${ episode . title } " from ${ episode . podcastName } . `
} ) ;
const errorMsgEl = bodyEl . createEl ( "p" , { text : error . message } ) ;
errorMsgEl . style . fontStyle = "italic" ;
} ) ;
}
setTimeout ( ( ) => notice . hide ( ) , 1e4 ) ;
} ) ;
}
function createNoticeDoc ( title ) {
const doc = new DocumentFragment ( ) ;
const container = doc . createDiv ( ) ;
container . style . width = "100%" ;
container . style . display = "flex" ;
const titleEl = container . createEl ( "span" , { text : title } ) ;
titleEl . style . textAlign = "center" ;
titleEl . style . fontWeight = "bold" ;
titleEl . style . marginBottom = "0.5em" ;
const bodyEl = doc . createDiv ( ) ;
bodyEl . style . display = "flex" ;
bodyEl . style . flexDirection = "column" ;
bodyEl . style . alignItems = "center" ;
bodyEl . style . justifyContent = "center" ;
return {
doc ,
update : ( updateFn , empty2 = true ) => {
if ( empty2 )
bodyEl . empty ( ) ;
updateFn ( bodyEl ) ;
}
} ;
}
function createEpisodeFile ( _0 ) {
return _ _async ( this , arguments , function * ( {
episode ,
downloadPathTemplate ,
blob ,
responseUrl
} ) {
const basename = DownloadPathTemplateEngine ( downloadPathTemplate , episode ) ;
const filePath = ` ${ basename } . ${ getUrlExtension ( responseUrl ) } ` ;
const buffer = yield blob . arrayBuffer ( ) ;
try {
yield app . vault . createBinary ( filePath , buffer ) ;
} catch ( error ) {
throw new Error ( ` Failed to write file " ${ filePath } ": ${ error . message } ` ) ;
}
downloadedEpisodes . addEpisode ( episode , filePath , blob . size ) ;
} ) ;
}
// src/ui/PodcastView/spawnEpisodeContextMenu.ts
function spawnEpisodeContextMenu ( episode , event , disabledMenuItems ) {
const menu = new import _obsidian15 . Menu ( ) ;
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . play ) ) {
menu . addItem ( ( item ) => item . setIcon ( "play" ) . setTitle ( "Play" ) . onClick ( ( ) => {
currentEpisode . set ( episode ) ;
viewState . set ( 2 /* Player */ ) ;
} ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . markPlayed ) ) {
const episodeIsPlayed = Object . values ( get _store _value ( playedEpisodes ) ) . find ( ( e ) => e . title === episode . title && e . finished ) ;
menu . addItem ( ( item ) => item . setIcon ( episodeIsPlayed ? "cross" : "check" ) . setTitle ( ` Mark as ${ episodeIsPlayed ? "Unplayed" : "Played" } ` ) . onClick ( ( ) => {
if ( episodeIsPlayed ) {
playedEpisodes . markAsUnplayed ( episode ) ;
} else {
playedEpisodes . markAsPlayed ( episode ) ;
}
} ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . download ) ) {
const isDownloaded = downloadedEpisodes . isEpisodeDownloaded ( episode ) ;
menu . addItem ( ( item ) => item . setIcon ( isDownloaded ? "cross" : "download" ) . setTitle ( isDownloaded ? "Remove file" : "Download" ) . onClick ( ( ) => {
if ( isDownloaded ) {
downloadedEpisodes . removeEpisode ( episode , true ) ;
} else {
const downloadPath = get _store _value ( plugin ) . settings . download . path ;
if ( ! downloadPath ) {
new import _obsidian15 . Notice ( ` Please set a download path in the settings. ` ) ;
return ;
}
downloadEpisodeWithNotice ( episode , downloadPath ) ;
}
} ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . createNote ) ) {
const episodeNoteExists = Boolean ( getPodcastNote ( episode ) ) ;
menu . addItem ( ( item ) => item . setIcon ( "pencil" ) . setTitle ( ` ${ episodeNoteExists ? "Open" : "Create" } Note ` ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
if ( episodeNoteExists ) {
openPodcastNote ( episode ) ;
} else {
const { path , template } = get _store _value ( plugin ) . settings . note ;
const canCreateNote = Boolean ( path && template ) ;
if ( ! canCreateNote ) {
new import _obsidian15 . Notice ( ` Please set a note path and template in the settings. ` ) ;
return ;
}
yield createPodcastNote ( episode ) ;
}
} ) ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . favorite ) ) {
const episodeIsFavorite = get _store _value ( favorites ) . episodes . find ( ( e ) => e . title === episode . title ) ;
menu . addItem ( ( item ) => item . setIcon ( "lucide-star" ) . setTitle ( ` ${ episodeIsFavorite ? "Remove from" : "Add to" } Favorites ` ) . onClick ( ( ) => {
if ( episodeIsFavorite ) {
favorites . update ( ( playlist ) => {
playlist . episodes = playlist . episodes . filter ( ( e ) => e . title !== episode . title ) ;
return playlist ;
} ) ;
} else {
favorites . update ( ( playlist ) => {
const newEpisodes = [ ... playlist . episodes , episode ] ;
playlist . episodes = newEpisodes ;
return playlist ;
} ) ;
}
} ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . queue ) ) {
const episodeIsInQueue = get _store _value ( queue ) . episodes . find ( ( e ) => e . title === episode . title ) ;
menu . addItem ( ( item ) => item . setIcon ( "list-ordered" ) . setTitle ( ` ${ episodeIsInQueue ? "Remove from" : "Add to" } Queue ` ) . onClick ( ( ) => {
if ( episodeIsInQueue ) {
queue . update ( ( playlist ) => {
playlist . episodes = playlist . episodes . filter ( ( e ) => e . title !== episode . title ) ;
return playlist ;
} ) ;
} else {
queue . update ( ( playlist ) => {
const newEpisodes = [ ... playlist . episodes , episode ] ;
playlist . episodes = newEpisodes ;
return playlist ;
} ) ;
}
} ) ) ;
}
if ( ! ( disabledMenuItems == null ? void 0 : disabledMenuItems . playlists ) ) {
menu . addSeparator ( ) ;
const playlistsInStore = get _store _value ( playlists ) ;
for ( const playlist of Object . values ( playlistsInStore ) ) {
const episodeIsInPlaylist = playlist . episodes . find ( ( e ) => e . title === episode . title ) ;
menu . addItem ( ( item ) => item . setIcon ( playlist . icon ) . setTitle ( ` ${ episodeIsInPlaylist ? "Remove from" : "Add to" } ${ playlist . name } ` ) . onClick ( ( ) => {
if ( episodeIsInPlaylist ) {
playlists . update ( ( playlists2 ) => {
playlists2 [ playlist . name ] . episodes = playlists2 [ playlist . name ] . episodes . filter ( ( e ) => e . title !== episode . title ) ;
return playlists2 ;
} ) ;
} else {
playlists . update ( ( playlists2 ) => {
const newEpisodes = [ ... playlists2 [ playlist . name ] . episodes , episode ] ;
playlists2 [ playlist . name ] . episodes = newEpisodes ;
return playlists2 ;
} ) ;
}
} ) ) ;
}
}
menu . showAtMouseEvent ( event ) ;
}
// src/utility/createMediaUrlObjectFromFilePath.ts
var import _obsidian16 = require ( "obsidian" ) ;
function createMediaUrlObjectFromFilePath ( filePath ) {
return _ _async ( this , null , function * ( ) {
const file = app . vault . getAbstractFileByPath ( filePath ) ;
if ( ! file || ! ( file instanceof import _obsidian16 . TFile ) )
return "" ;
const binary = yield app . vault . readBinary ( file ) ;
return URL . createObjectURL ( new Blob ( [ binary ] , { type : "audio/mpeg" } ) ) ;
} ) ;
}
// src/ui/PodcastView/EpisodePlayer.svelte
function add _css14 ( target ) {
append _styles ( target , "svelte-1itadba" , ".episode-player{display:flex;flex-direction:column;height:100%}.episode-image-container{width:100%;height:auto;padding:5% 0%}.hover-container{min-width:10rem;min-height:10rem;width:100%;height:100%;aspect-ratio:1/1;display:flex;align-items:center;justify-content:center;position:relative;margin-left:auto;margin-right:auto}.podcast-artwork{width:100%;height:100%;background-size:cover;background-position:center;background-repeat:no-repeat;position:absolute}.podcast-artwork-placeholder{width:100%;height:100%;background-size:cover;background-position:center;background-repeat:no-repeat;position:absolute;display:flex;align-items:center;justify-content:center}.podcast-artwork:hover{cursor:pointer !important}.podcast-artwork-overlay{position:absolute}.podcast-artwork-isloading-overlay{position:absolute;display:block}.podcast-artwork-overlay:hover{cursor:pointer !important}.opacity-50{opacity:0.5}.podcast-title{font-size:1.5rem;font-weight:bold;margin:0%;margin-bottom:0.5rem;text-align:center}.status-container{display:flex;align-items:center;justify-content:space-around}.controls-container{display:flex;align-items:center;justify-content:space-between;margin-top:1rem;margin-left:25%;margin-right:25%}.playbackrate-container{display:flex;align-items:center;justify-content:space-around;margin-bottom:2.5rem;flex-direction:column;margin-top:auto}" ) ;
}
function create _fallback _slot ( ctx ) {
let div ;
let icon ;
let div _class _value ;
let current ;
icon = new Icon _default ( { props : { icon : "image" , size : 150 } } ) ;
return {
c ( ) {
div = element ( "div" ) ;
create _component ( icon . $$ . fragment ) ;
attr ( div , "class" , div _class _value = "podcast-artwork-placeholder" + ( ctx [ 2 ] || ctx [ 9 ] ? " opacity-50" : "" ) ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( icon , div , null ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
if ( ! current || dirty [ 0 ] & 516 && div _class _value !== ( div _class _value = "podcast-artwork-placeholder" + ( ctx2 [ 2 ] || ctx2 [ 9 ] ? " opacity-50" : "" ) ) ) {
attr ( div , "class" , div _class _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( icon ) ;
}
} ;
}
function create _else _block2 ( ctx ) {
let div ;
let icon ;
let div _style _value ;
let current ;
icon = new Icon _default ( {
props : {
icon : ctx [ 9 ] ? "play" : "pause"
}
} ) ;
return {
c ( ) {
div = element ( "div" ) ;
create _component ( icon . $$ . fragment ) ;
attr ( div , "class" , "podcast-artwork-overlay" ) ;
attr ( div , "style" , div _style _value = ` display: ${ ctx [ 2 ] || ctx [ 9 ] ? "block" : "none" } ` ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( icon , div , null ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const icon _changes = { } ;
if ( dirty [ 0 ] & 512 )
icon _changes . icon = ctx2 [ 9 ] ? "play" : "pause" ;
icon . $set ( icon _changes ) ;
if ( ! current || dirty [ 0 ] & 516 && div _style _value !== ( div _style _value = ` display: ${ ctx2 [ 2 ] || ctx2 [ 9 ] ? "block" : "none" } ` ) ) {
attr ( div , "style" , div _style _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( icon ) ;
}
} ;
}
function create _if _block7 ( ctx ) {
let div ;
let loading ;
let current ;
loading = new Loading _default ( { } ) ;
return {
c ( ) {
div = element ( "div" ) ;
create _component ( loading . $$ . fragment ) ;
attr ( div , "class" , "podcast-artwork-isloading-overlay" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( loading , div , null ) ;
current = true ;
} ,
p : noop ,
i ( local ) {
if ( current )
return ;
transition _in ( loading . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( loading . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( loading ) ;
}
} ;
}
function create _catch _block ( ctx ) {
return { c : noop , m : noop , p : noop , d : noop } ;
}
function create _then _block ( ctx ) {
let audio ;
let audio _src _value ;
let audio _autoplay _value ;
let audio _updating = false ;
let audio _animationframe ;
let audio _is _paused = true ;
let mounted ;
let dispose ;
function audio _timeupdate _handler ( ) {
cancelAnimationFrame ( audio _animationframe ) ;
if ( ! audio . paused ) {
audio _animationframe = raf ( audio _timeupdate _handler ) ;
audio _updating = true ;
}
ctx [ 23 ] . call ( audio ) ;
}
return {
c ( ) {
audio = element ( "audio" ) ;
if ( ! src _url _equal ( audio . src , audio _src _value = ctx [ 31 ] ) )
attr ( audio , "src" , audio _src _value ) ;
audio . autoplay = audio _autoplay _value = true ;
if ( ctx [ 6 ] === void 0 )
add _render _callback ( ( ) => ctx [ 22 ] . call ( audio ) ) ;
} ,
m ( target , anchor ) {
insert ( target , audio , anchor ) ;
if ( ! isNaN ( ctx [ 1 ] . _playbackRate ) ) {
audio . playbackRate = ctx [ 1 ] . _playbackRate ;
}
if ( ! mounted ) {
dispose = [
listen ( audio , "durationchange" , ctx [ 22 ] ) ,
listen ( audio , "timeupdate" , audio _timeupdate _handler ) ,
listen ( audio , "play" , ctx [ 24 ] ) ,
listen ( audio , "pause" , ctx [ 24 ] ) ,
listen ( audio , "ratechange" , ctx [ 25 ] ) ,
listen ( audio , "ended" , ctx [ 13 ] ) ,
listen ( audio , "loadedmetadata" , ctx [ 15 ] ) ,
listen ( audio , "play" , prevent _default ( ctx [ 19 ] ) )
] ;
mounted = true ;
}
} ,
p ( ctx2 , dirty ) {
if ( dirty [ 0 ] & 16 && ! src _url _equal ( audio . src , audio _src _value = ctx2 [ 31 ] ) ) {
attr ( audio , "src" , audio _src _value ) ;
}
if ( ! audio _updating && dirty [ 0 ] & 1 && ! isNaN ( ctx2 [ 0 ] ) ) {
audio . currentTime = ctx2 [ 0 ] ;
}
audio _updating = false ;
if ( dirty [ 0 ] & 512 && audio _is _paused !== ( audio _is _paused = ctx2 [ 9 ] ) ) {
audio [ audio _is _paused ? "pause" : "play" ] ( ) ;
}
if ( dirty [ 0 ] & 2 && ! isNaN ( ctx2 [ 1 ] . _playbackRate ) ) {
audio . playbackRate = ctx2 [ 1 ] . _playbackRate ;
}
} ,
d ( detaching ) {
if ( detaching )
detach ( audio ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function create _pending _block ( ctx ) {
return { c : noop , m : noop , p : noop , d : noop } ;
}
function create _header _slot ( ctx ) {
let h3 ;
return {
c ( ) {
h3 = element ( "h3" ) ;
h3 . textContent = "Queue" ;
} ,
m ( target , anchor ) {
insert ( target , h3 , anchor ) ;
} ,
p : noop ,
d ( detaching ) {
if ( detaching )
detach ( h3 ) ;
}
} ;
}
function create _fragment20 ( ctx ) {
var _a ;
let div5 ;
let div1 ;
let div0 ;
let image ;
let t0 ;
let current _block _type _index ;
let if _block ;
let t1 ;
let h2 ;
let t2 _value = ctx [ 5 ] . title + "" ;
let t2 ;
let t3 ;
let promise ;
let t4 ;
let div2 ;
let span0 ;
let t5 _value = formatSeconds ( ctx [ 7 ] , "HH:mm:ss" ) + "" ;
let t5 ;
let t6 ;
let progressbar ;
let t7 ;
let span1 ;
let t8 _value = formatSeconds ( ctx [ 6 ] - ctx [ 7 ] , "HH:mm:ss" ) + "" ;
let t8 ;
let t9 ;
let div3 ;
let button0 ;
let t10 ;
let button1 ;
let t11 ;
let div4 ;
let span2 ;
let t12 _value = ctx [ 1 ] . playbackRate + "" ;
let t12 ;
let t13 ;
let t14 ;
let slider ;
let t15 ;
let episodelist ;
let current ;
let mounted ;
let dispose ;
image = new Image _default ( {
props : {
class : "podcast-artwork" ,
src : ( _a = ctx [ 5 ] . artworkUrl ) != null ? _a : "" ,
alt : ctx [ 5 ] . title ,
opacity : ctx [ 2 ] || ctx [ 9 ] ? 0.5 : 1 ,
$$slots : { fallback : [ create _fallback _slot ] } ,
$$scope : { ctx }
}
} ) ;
const if _block _creators = [ create _if _block7 , create _else _block2 ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx2 , dirty ) {
if ( ctx2 [ 3 ] )
return 0 ;
return 1 ;
}
current _block _type _index = select _block _type ( ctx , [ - 1 , - 1 ] ) ;
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
let info = {
ctx ,
current : null ,
token : null ,
hasCatch : false ,
pending : create _pending _block ,
then : create _then _block ,
catch : create _catch _block ,
value : 31
} ;
handle _promise ( promise = ctx [ 4 ] , info ) ;
progressbar = new Progressbar _default ( {
props : {
value : ctx [ 7 ] ,
max : ctx [ 6 ] ,
style : { "height" : "2rem" }
}
} ) ;
progressbar . $on ( "click" , ctx [ 12 ] ) ;
button0 = new Button _default ( {
props : {
icon : "skip-back" ,
tooltip : "Skip backward" ,
style : { margin : "0" , cursor : "pointer" }
}
} ) ;
button0 . $on ( "click" , function ( ) {
if ( is _function ( ctx [ 8 ] . api . skipBackward . bind ( ctx [ 8 ] . api ) ) )
ctx [ 8 ] . api . skipBackward . bind ( ctx [ 8 ] . api ) . apply ( this , arguments ) ;
} ) ;
button1 = new Button _default ( {
props : {
icon : "skip-forward" ,
tooltip : "Skip forward" ,
style : { margin : "0" , cursor : "pointer" }
}
} ) ;
button1 . $on ( "click" , function ( ) {
if ( is _function ( ctx [ 8 ] . api . skipForward . bind ( ctx [ 8 ] . api ) ) )
ctx [ 8 ] . api . skipForward . bind ( ctx [ 8 ] . api ) . apply ( this , arguments ) ;
} ) ;
slider = new Slider _default ( {
props : {
value : ctx [ 1 ] . playbackRate ,
limits : [ 0.5 , 3.5 , 0.1 ]
}
} ) ;
slider . $on ( "change" , ctx [ 14 ] ) ;
episodelist = new EpisodeList _default ( {
props : {
episodes : ctx [ 10 ] . episodes ,
showListMenu : false ,
showThumbnails : true ,
$$slots : { header : [ create _header _slot ] } ,
$$scope : { ctx }
}
} ) ;
episodelist . $on ( "contextMenuEpisode" , ctx [ 16 ] ) ;
episodelist . $on ( "clickEpisode" , ctx [ 18 ] ) ;
return {
c ( ) {
div5 = element ( "div" ) ;
div1 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( image . $$ . fragment ) ;
t0 = space ( ) ;
if _block . c ( ) ;
t1 = space ( ) ;
h2 = element ( "h2" ) ;
t2 = text ( t2 _value ) ;
t3 = space ( ) ;
info . block . c ( ) ;
t4 = space ( ) ;
div2 = element ( "div" ) ;
span0 = element ( "span" ) ;
t5 = text ( t5 _value ) ;
t6 = space ( ) ;
create _component ( progressbar . $$ . fragment ) ;
t7 = space ( ) ;
span1 = element ( "span" ) ;
t8 = text ( t8 _value ) ;
t9 = space ( ) ;
div3 = element ( "div" ) ;
create _component ( button0 . $$ . fragment ) ;
t10 = space ( ) ;
create _component ( button1 . $$ . fragment ) ;
t11 = space ( ) ;
div4 = element ( "div" ) ;
span2 = element ( "span" ) ;
t12 = text ( t12 _value ) ;
t13 = text ( "x" ) ;
t14 = space ( ) ;
create _component ( slider . $$ . fragment ) ;
t15 = space ( ) ;
create _component ( episodelist . $$ . fragment ) ;
attr ( div0 , "class" , "hover-container" ) ;
attr ( div1 , "class" , "episode-image-container" ) ;
attr ( h2 , "class" , "podcast-title" ) ;
attr ( div2 , "class" , "status-container" ) ;
attr ( div3 , "class" , "controls-container" ) ;
attr ( div4 , "class" , "playbackrate-container" ) ;
attr ( div5 , "class" , "episode-player" ) ;
} ,
m ( target , anchor ) {
insert ( target , div5 , anchor ) ;
append ( div5 , div1 ) ;
append ( div1 , div0 ) ;
mount _component ( image , div0 , null ) ;
append ( div0 , t0 ) ;
if _blocks [ current _block _type _index ] . m ( div0 , null ) ;
append ( div5 , t1 ) ;
append ( div5 , h2 ) ;
append ( h2 , t2 ) ;
append ( div5 , t3 ) ;
info . block . m ( div5 , info . anchor = null ) ;
info . mount = ( ) => div5 ;
info . anchor = t4 ;
append ( div5 , t4 ) ;
append ( div5 , div2 ) ;
append ( div2 , span0 ) ;
append ( span0 , t5 ) ;
append ( div2 , t6 ) ;
mount _component ( progressbar , div2 , null ) ;
append ( div2 , t7 ) ;
append ( div2 , span1 ) ;
append ( span1 , t8 ) ;
append ( div5 , t9 ) ;
append ( div5 , div3 ) ;
mount _component ( button0 , div3 , null ) ;
append ( div3 , t10 ) ;
mount _component ( button1 , div3 , null ) ;
append ( div5 , t11 ) ;
append ( div5 , div4 ) ;
append ( div4 , span2 ) ;
append ( span2 , t12 ) ;
append ( span2 , t13 ) ;
append ( div4 , t14 ) ;
mount _component ( slider , div4 , null ) ;
append ( div5 , t15 ) ;
mount _component ( episodelist , div5 , null ) ;
current = true ;
if ( ! mounted ) {
dispose = [
listen ( div0 , "click" , ctx [ 11 ] ) ,
listen ( div0 , "contextmenu" , ctx [ 17 ] ) ,
listen ( div0 , "mouseenter" , ctx [ 20 ] ) ,
listen ( div0 , "mouseleave" , ctx [ 21 ] )
] ;
mounted = true ;
}
} ,
p ( new _ctx , dirty ) {
var _a2 ;
ctx = new _ctx ;
const image _changes = { } ;
if ( dirty [ 0 ] & 32 )
image _changes . src = ( _a2 = ctx [ 5 ] . artworkUrl ) != null ? _a2 : "" ;
if ( dirty [ 0 ] & 32 )
image _changes . alt = ctx [ 5 ] . title ;
if ( dirty [ 0 ] & 516 )
image _changes . opacity = ctx [ 2 ] || ctx [ 9 ] ? 0.5 : 1 ;
if ( dirty [ 0 ] & 516 | dirty [ 1 ] & 2 ) {
image _changes . $$scope = { dirty , ctx } ;
}
image . $set ( image _changes ) ;
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type ( ctx , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if _blocks [ current _block _type _index ] . p ( ctx , dirty ) ;
} else {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
if _block = if _blocks [ current _block _type _index ] ;
if ( ! if _block ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
if _block . c ( ) ;
} else {
if _block . p ( ctx , dirty ) ;
}
transition _in ( if _block , 1 ) ;
if _block . m ( div0 , null ) ;
}
if ( ( ! current || dirty [ 0 ] & 32 ) && t2 _value !== ( t2 _value = ctx [ 5 ] . title + "" ) )
set _data ( t2 , t2 _value ) ;
info . ctx = ctx ;
if ( dirty [ 0 ] & 16 && promise !== ( promise = ctx [ 4 ] ) && handle _promise ( promise , info ) ) {
} else {
update _await _block _branch ( info , ctx , dirty ) ;
}
if ( ( ! current || dirty [ 0 ] & 128 ) && t5 _value !== ( t5 _value = formatSeconds ( ctx [ 7 ] , "HH:mm:ss" ) + "" ) )
set _data ( t5 , t5 _value ) ;
const progressbar _changes = { } ;
if ( dirty [ 0 ] & 128 )
progressbar _changes . value = ctx [ 7 ] ;
if ( dirty [ 0 ] & 64 )
progressbar _changes . max = ctx [ 6 ] ;
progressbar . $set ( progressbar _changes ) ;
if ( ( ! current || dirty [ 0 ] & 192 ) && t8 _value !== ( t8 _value = formatSeconds ( ctx [ 6 ] - ctx [ 7 ] , "HH:mm:ss" ) + "" ) )
set _data ( t8 , t8 _value ) ;
if ( ( ! current || dirty [ 0 ] & 2 ) && t12 _value !== ( t12 _value = ctx [ 1 ] . playbackRate + "" ) )
set _data ( t12 , t12 _value ) ;
const slider _changes = { } ;
if ( dirty [ 0 ] & 2 )
slider _changes . value = ctx [ 1 ] . playbackRate ;
slider . $set ( slider _changes ) ;
const episodelist _changes = { } ;
if ( dirty [ 0 ] & 1024 )
episodelist _changes . episodes = ctx [ 10 ] . episodes ;
if ( dirty [ 1 ] & 2 ) {
episodelist _changes . $$scope = { dirty , ctx } ;
}
episodelist . $set ( episodelist _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( image . $$ . fragment , local ) ;
transition _in ( if _block ) ;
transition _in ( progressbar . $$ . fragment , local ) ;
transition _in ( button0 . $$ . fragment , local ) ;
transition _in ( button1 . $$ . fragment , local ) ;
transition _in ( slider . $$ . fragment , local ) ;
transition _in ( episodelist . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( image . $$ . fragment , local ) ;
transition _out ( if _block ) ;
transition _out ( progressbar . $$ . fragment , local ) ;
transition _out ( button0 . $$ . fragment , local ) ;
transition _out ( button1 . $$ . fragment , local ) ;
transition _out ( slider . $$ . fragment , local ) ;
transition _out ( episodelist . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div5 ) ;
destroy _component ( image ) ;
if _blocks [ current _block _type _index ] . d ( ) ;
info . block . d ( ) ;
info . token = null ;
info = null ;
destroy _component ( progressbar ) ;
destroy _component ( button0 ) ;
destroy _component ( button1 ) ;
destroy _component ( slider ) ;
destroy _component ( episodelist ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function instance19 ( $$self , $$props , $$invalidate ) {
let $currentEpisode ;
let $duration ;
let $currentTime ;
let $playedEpisodes ;
let $plugin ;
let $isPaused ;
let $queue ;
component _subscribe ( $$self , currentEpisode , ( $$value ) => $$invalidate ( 5 , $currentEpisode = $$value ) ) ;
component _subscribe ( $$self , duration , ( $$value ) => $$invalidate ( 6 , $duration = $$value ) ) ;
component _subscribe ( $$self , currentTime , ( $$value ) => $$invalidate ( 7 , $currentTime = $$value ) ) ;
component _subscribe ( $$self , playedEpisodes , ( $$value ) => $$invalidate ( 26 , $playedEpisodes = $$value ) ) ;
component _subscribe ( $$self , plugin , ( $$value ) => $$invalidate ( 8 , $plugin = $$value ) ) ;
component _subscribe ( $$self , isPaused , ( $$value ) => $$invalidate ( 9 , $isPaused = $$value ) ) ;
component _subscribe ( $$self , queue , ( $$value ) => $$invalidate ( 10 , $queue = $$value ) ) ;
class CircumentForcedTwoWayBinding {
constructor ( ) {
this . playbackRate = $plugin . settings . defaultPlaybackRate || 1 ;
}
get _playbackRate ( ) {
return this . playbackRate ;
}
}
const offBinding = new CircumentForcedTwoWayBinding ( ) ;
let isHoveringArtwork = false ;
let isLoading = true ;
function togglePlayback ( ) {
isPaused . update ( ( value ) => ! value ) ;
}
function onClickProgressbar ( { detail : { event } } ) {
const progressbar = event . target ;
const percent = event . offsetX / progressbar . offsetWidth ;
currentTime . set ( percent * $duration ) ;
}
function removeEpisodeFromPlaylists ( ) {
playlists . update ( ( lists ) => {
Object . values ( lists ) . forEach ( ( playlist ) => {
playlist . episodes = playlist . episodes . filter ( ( ep ) => ep . title !== $currentEpisode . title ) ;
} ) ;
return lists ;
} ) ;
queue . remove ( $currentEpisode ) ;
}
function onEpisodeEnded ( ) {
playedEpisodes . markAsPlayed ( $currentEpisode ) ;
removeEpisodeFromPlaylists ( ) ;
queue . playNext ( ) ;
}
function onPlaybackRateChange ( event ) {
$$invalidate ( 1 , offBinding . playbackRate = event . detail . value , offBinding ) ;
}
function onMetadataLoaded ( ) {
$$invalidate ( 3 , isLoading = false ) ;
restorePlaybackTime ( ) ;
}
function restorePlaybackTime ( ) {
const playedEps = $playedEpisodes ;
const currentEp = $currentEpisode ;
if ( playedEps [ currentEp . title ] ) {
currentTime . set ( playedEps [ currentEp . title ] . time ) ;
} else {
currentTime . set ( 0 ) ;
}
isPaused . set ( false ) ;
}
let srcPromise = getSrc ( $currentEpisode ) ;
let playerTime = 0 ;
onMount ( ( ) => {
const unsub = currentTime . subscribe ( ( ct ) => {
$$invalidate ( 0 , playerTime = ct ) ;
} ) ;
const unsubDownloadedSource = downloadedEpisodes . subscribe ( ( _ ) => {
$$invalidate ( 4 , srcPromise = getSrc ( $currentEpisode ) ) ;
} ) ;
const unsubCurrentEpisode = currentEpisode . subscribe ( ( _ ) => {
$$invalidate ( 4 , srcPromise = getSrc ( $currentEpisode ) ) ;
} ) ;
return ( ) => {
unsub ( ) ;
unsubDownloadedSource ( ) ;
unsubCurrentEpisode ( ) ;
} ;
} ) ;
onDestroy ( ( ) => {
playedEpisodes . setEpisodeTime ( $currentEpisode , $currentTime , $duration , $currentTime === $duration ) ;
isPaused . set ( true ) ;
} ) ;
function handleContextMenuEpisode ( { detail : { event , episode } } ) {
spawnEpisodeContextMenu ( episode , event ) ;
}
function handleContextMenuEpisodeImage ( event ) {
spawnEpisodeContextMenu ( $currentEpisode , event , { play : true , markPlayed : true } ) ;
}
function handleClickEpisode ( event ) {
const { episode } = event . detail ;
currentEpisode . set ( episode ) ;
viewState . set ( 2 /* Player */ ) ;
}
function getSrc ( episode ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( downloadedEpisodes . isEpisodeDownloaded ( episode ) ) {
const downloadedEpisode = downloadedEpisodes . getEpisode ( episode ) ;
if ( ! downloadedEpisode )
return "" ;
return createMediaUrlObjectFromFilePath ( downloadedEpisode . filePath ) ;
}
return episode . streamUrl ;
} ) ;
}
function play _handler ( event ) {
bubble . call ( this , $$self , event ) ;
}
const mouseenter _handler = ( ) => $$invalidate ( 2 , isHoveringArtwork = true ) ;
const mouseleave _handler = ( ) => $$invalidate ( 2 , isHoveringArtwork = false ) ;
function audio _durationchange _handler ( ) {
$duration = this . duration ;
duration . set ( $duration ) ;
}
function audio _timeupdate _handler ( ) {
playerTime = this . currentTime ;
$$invalidate ( 0 , playerTime ) ;
}
function audio _play _pause _handler ( ) {
$isPaused = this . paused ;
isPaused . set ( $isPaused ) ;
}
function audio _ratechange _handler ( ) {
offBinding . _playbackRate = this . playbackRate ;
$$invalidate ( 1 , offBinding ) ;
}
$$self . $$ . update = ( ) => {
if ( $$self . $$ . dirty [ 0 ] & 1 ) {
$ : {
currentTime . set ( playerTime ) ;
}
}
} ;
return [
playerTime ,
offBinding ,
isHoveringArtwork ,
isLoading ,
srcPromise ,
$currentEpisode ,
$duration ,
$currentTime ,
$plugin ,
$isPaused ,
$queue ,
togglePlayback ,
onClickProgressbar ,
onEpisodeEnded ,
onPlaybackRateChange ,
onMetadataLoaded ,
handleContextMenuEpisode ,
handleContextMenuEpisodeImage ,
handleClickEpisode ,
play _handler ,
mouseenter _handler ,
mouseleave _handler ,
audio _durationchange _handler ,
audio _timeupdate _handler ,
audio _play _pause _handler ,
audio _ratechange _handler
] ;
}
var EpisodePlayer = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance19 , create _fragment20 , safe _not _equal , { } , add _css14 , [ - 1 , - 1 ] ) ;
}
} ;
var EpisodePlayer _default = EpisodePlayer ;
// src/ui/PodcastView/TopBar.svelte
function add _css15 ( target ) {
append _styles ( target , "svelte-shb2ik" , ".topbar-container.svelte-shb2ik{display:flex;flex-direction:row;align-items:center;justify-content:space-between;height:50px;min-height:50px;border-bottom:1px solid var(--background-divider)}.topbar-menu-button.svelte-shb2ik{display:flex;align-items:center;justify-content:center;width:100%;height:100%;opacity:0.1}.topbar-selected.svelte-shb2ik{opacity:1 !important}.topbar-selectable.svelte-shb2ik{cursor:pointer;opacity:0.5}" ) ;
}
function create _fragment21 ( ctx ) {
let div3 ;
let div0 ;
let icon0 ;
let div0 _class _value ;
let t0 ;
let div1 ;
let icon1 ;
let div1 _class _value ;
let t1 ;
let div2 ;
let icon2 ;
let div2 _class _value ;
let current ;
let mounted ;
let dispose ;
icon0 = new Icon _default ( { props : { icon : "grid" , size : 20 } } ) ;
icon1 = new Icon _default ( { props : { icon : "list-minus" , size : 20 } } ) ;
icon2 = new Icon _default ( { props : { icon : "play" , size : 20 } } ) ;
return {
c ( ) {
div3 = element ( "div" ) ;
div0 = element ( "div" ) ;
create _component ( icon0 . $$ . fragment ) ;
t0 = space ( ) ;
div1 = element ( "div" ) ;
create _component ( icon1 . $$ . fragment ) ;
t1 = space ( ) ;
div2 = element ( "div" ) ;
create _component ( icon2 . $$ . fragment ) ;
attr ( div0 , "class" , div0 _class _value = null _to _empty ( `
topbar - menu - button
topbar - selectable
$ { ctx [ 0 ] === 0 /* PodcastGrid */ ? "topbar-selected" : "" }
` ) + " svelte-shb2ik");
attr ( div0 , "aria-label" , "Podcast grid" ) ;
attr ( div1 , "class" , div1 _class _value = null _to _empty ( `
topbar - menu - button
$ { ctx [ 0 ] === 1 /* EpisodeList */ ? "topbar-selected" : "" }
$ { ctx [ 1 ] ? "topbar-selectable" : "" }
` ) + " svelte-shb2ik");
attr ( div1 , "aria-label" , "Episode list" ) ;
attr ( div2 , "class" , div2 _class _value = null _to _empty ( `
topbar - menu - button
$ { ctx [ 0 ] === 2 /* Player */ ? "topbar-selected" : "" }
$ { ctx [ 2 ] ? "topbar-selectable" : "" }
` ) + " svelte-shb2ik");
attr ( div2 , "aria-label" , "Player" ) ;
attr ( div3 , "class" , "topbar-container svelte-shb2ik" ) ;
} ,
m ( target , anchor ) {
insert ( target , div3 , anchor ) ;
append ( div3 , div0 ) ;
mount _component ( icon0 , div0 , null ) ;
append ( div3 , t0 ) ;
append ( div3 , div1 ) ;
mount _component ( icon1 , div1 , null ) ;
append ( div3 , t1 ) ;
append ( div3 , div2 ) ;
mount _component ( icon2 , div2 , null ) ;
current = true ;
if ( ! mounted ) {
dispose = [
listen ( div0 , "click" , ctx [ 3 ] . bind ( null , 0 /* PodcastGrid */ ) ) ,
listen ( div1 , "click" , ctx [ 3 ] . bind ( null , 1 /* EpisodeList */ ) ) ,
listen ( div2 , "click" , ctx [ 3 ] . bind ( null , 2 /* Player */ ) )
] ;
mounted = true ;
}
} ,
p ( ctx2 , [ dirty ] ) {
if ( ! current || dirty & 1 && div0 _class _value !== ( div0 _class _value = null _to _empty ( `
topbar - menu - button
topbar - selectable
$ { ctx2 [ 0 ] === 0 /* PodcastGrid */ ? "topbar-selected" : "" }
` ) + " svelte-shb2ik")) {
attr ( div0 , "class" , div0 _class _value ) ;
}
if ( ! current || dirty & 3 && div1 _class _value !== ( div1 _class _value = null _to _empty ( `
topbar - menu - button
$ { ctx2 [ 0 ] === 1 /* EpisodeList */ ? "topbar-selected" : "" }
$ { ctx2 [ 1 ] ? "topbar-selectable" : "" }
` ) + " svelte-shb2ik")) {
attr ( div1 , "class" , div1 _class _value ) ;
}
if ( ! current || dirty & 5 && div2 _class _value !== ( div2 _class _value = null _to _empty ( `
topbar - menu - button
$ { ctx2 [ 0 ] === 2 /* Player */ ? "topbar-selected" : "" }
$ { ctx2 [ 2 ] ? "topbar-selectable" : "" }
` ) + " svelte-shb2ik")) {
attr ( div2 , "class" , div2 _class _value ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon0 . $$ . fragment , local ) ;
transition _in ( icon1 . $$ . fragment , local ) ;
transition _in ( icon2 . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon0 . $$ . fragment , local ) ;
transition _out ( icon1 . $$ . fragment , local ) ;
transition _out ( icon2 . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div3 ) ;
destroy _component ( icon0 ) ;
destroy _component ( icon1 ) ;
destroy _component ( icon2 ) ;
mounted = false ;
run _all ( dispose ) ;
}
} ;
}
function instance20 ( $$self , $$props , $$invalidate ) {
let { viewState : viewState2 = 0 /* PodcastGrid */ } = $$props ;
let { canShowEpisodeList = false } = $$props ;
let { canShowPlayer = false } = $$props ;
function handleClickMenuItem ( newState ) {
if ( viewState2 === newState )
return ;
if ( newState === 1 /* EpisodeList */ && ! canShowEpisodeList )
return ;
if ( newState === 2 /* Player */ && ! canShowPlayer )
return ;
$$invalidate ( 0 , viewState2 = newState ) ;
}
$$self . $$set = ( $$props2 ) => {
if ( "viewState" in $$props2 )
$$invalidate ( 0 , viewState2 = $$props2 . viewState ) ;
if ( "canShowEpisodeList" in $$props2 )
$$invalidate ( 1 , canShowEpisodeList = $$props2 . canShowEpisodeList ) ;
if ( "canShowPlayer" in $$props2 )
$$invalidate ( 2 , canShowPlayer = $$props2 . canShowPlayer ) ;
} ;
return [ viewState2 , canShowEpisodeList , canShowPlayer , handleClickMenuItem ] ;
}
var TopBar = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance20 , create _fragment21 , safe _not _equal , {
viewState : 0 ,
canShowEpisodeList : 1 ,
canShowPlayer : 2
} , add _css15 ) ;
}
} ;
var TopBar _default = TopBar ;
// src/ui/PodcastView/EpisodeListHeader.svelte
function add _css16 ( target ) {
append _styles ( target , "svelte-uuatlf" , ".podcast-header.svelte-uuatlf{display:flex;flex-direction:column;justify-content:space-around;align-items:center;padding:0.5rem}.podcast-heading.svelte-uuatlf{text-align:center}" ) ;
}
function create _if _block8 ( ctx ) {
let img ;
let img _src _value ;
return {
c ( ) {
img = element ( "img" ) ;
attr ( img , "id" , "podcast-artwork" ) ;
if ( ! src _url _equal ( img . src , img _src _value = ctx [ 1 ] ) )
attr ( img , "src" , img _src _value ) ;
attr ( img , "alt" , ctx [ 0 ] ) ;
} ,
m ( target , anchor ) {
insert ( target , img , anchor ) ;
} ,
p ( ctx2 , dirty ) {
if ( dirty & 2 && ! src _url _equal ( img . src , img _src _value = ctx2 [ 1 ] ) ) {
attr ( img , "src" , img _src _value ) ;
}
if ( dirty & 1 ) {
attr ( img , "alt" , ctx2 [ 0 ] ) ;
}
} ,
d ( detaching ) {
if ( detaching )
detach ( img ) ;
}
} ;
}
function create _fragment22 ( ctx ) {
let div ;
let t0 ;
let h2 ;
let t1 ;
let if _block = ctx [ 1 ] && create _if _block8 ( ctx ) ;
return {
c ( ) {
div = element ( "div" ) ;
if ( if _block )
if _block . c ( ) ;
t0 = space ( ) ;
h2 = element ( "h2" ) ;
t1 = text ( ctx [ 0 ] ) ;
attr ( h2 , "class" , "podcast-heading svelte-uuatlf" ) ;
attr ( div , "class" , "podcast-header svelte-uuatlf" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
if ( if _block )
if _block . m ( div , null ) ;
append ( div , t0 ) ;
append ( div , h2 ) ;
append ( h2 , t1 ) ;
} ,
p ( ctx2 , [ dirty ] ) {
if ( ctx2 [ 1 ] ) {
if ( if _block ) {
if _block . p ( ctx2 , dirty ) ;
} else {
if _block = create _if _block8 ( ctx2 ) ;
if _block . c ( ) ;
if _block . m ( div , t0 ) ;
}
} else if ( if _block ) {
if _block . d ( 1 ) ;
if _block = null ;
}
if ( dirty & 1 )
set _data ( t1 , ctx2 [ 0 ] ) ;
} ,
i : noop ,
o : noop ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
if ( if _block )
if _block . d ( ) ;
}
} ;
}
function instance21 ( $$self , $$props , $$invalidate ) {
let { text : text2 = "" } = $$props ;
let { artworkUrl = "" } = $$props ;
$$self . $$set = ( $$props2 ) => {
if ( "text" in $$props2 )
$$invalidate ( 0 , text2 = $$props2 . text ) ;
if ( "artworkUrl" in $$props2 )
$$invalidate ( 1 , artworkUrl = $$props2 . artworkUrl ) ;
} ;
return [ text2 , artworkUrl ] ;
}
var EpisodeListHeader = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance21 , create _fragment22 , safe _not _equal , { text : 0 , artworkUrl : 1 } , add _css16 ) ;
}
} ;
var EpisodeListHeader _default = EpisodeListHeader ;
// src/ui/PodcastView/PodcastView.svelte
var import _obsidian17 = require ( "obsidian" ) ;
// src/utility/searchEpisodes.ts
function searchEpisodes ( query , episodes ) {
if ( episodes . length === 0 )
return [ ] ;
if ( query . length === 0 ) {
return episodes ;
}
const fuse = new Fuse ( episodes , {
shouldSort : true ,
findAllMatches : true ,
threshold : 0.4 ,
isCaseSensitive : false ,
keys : [ "title" ]
} ) ;
const searchResults = fuse . search ( query ) ;
return searchResults . map ( ( resItem ) => resItem . item ) ;
}
// src/ui/PodcastView/PodcastView.svelte
function add _css17 ( target ) {
append _styles ( target , "svelte-unmvd4" , ".podcast-view.svelte-unmvd4{display:flex;flex-direction:column;height:100%}.go-back.svelte-unmvd4{display:flex;align-items:center;justify-content:center;padding:0.5rem;gap:0.5rem;cursor:pointer;margin-right:auto;opacity:0.75}.go-back.svelte-unmvd4:hover{opacity:1}" ) ;
}
function create _if _block _4 ( ctx ) {
let podcastgrid ;
let current ;
podcastgrid = new PodcastGrid _default ( {
props : {
feeds : ctx [ 0 ] ,
playlists : ctx [ 4 ]
}
} ) ;
podcastgrid . $on ( "clickPodcast" , ctx [ 9 ] ) ;
podcastgrid . $on ( "clickPlaylist" , ctx [ 14 ] ) ;
return {
c ( ) {
create _component ( podcastgrid . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( podcastgrid , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const podcastgrid _changes = { } ;
if ( dirty & 1 )
podcastgrid _changes . feeds = ctx2 [ 0 ] ;
if ( dirty & 16 )
podcastgrid _changes . playlists = ctx2 [ 4 ] ;
podcastgrid . $set ( podcastgrid _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( podcastgrid . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( podcastgrid . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( podcastgrid , detaching ) ;
}
} ;
}
function create _if _block _15 ( ctx ) {
let episodelist ;
let current ;
episodelist = new EpisodeList _default ( {
props : {
episodes : ctx [ 3 ] ,
showThumbnails : ! ctx [ 1 ] || ! ctx [ 2 ] ,
$$slots : { header : [ create _header _slot2 ] } ,
$$scope : { ctx }
}
} ) ;
episodelist . $on ( "clickEpisode" , ctx [ 10 ] ) ;
episodelist . $on ( "contextMenuEpisode" , ctx [ 11 ] ) ;
episodelist . $on ( "clickRefresh" , ctx [ 12 ] ) ;
episodelist . $on ( "search" , ctx [ 13 ] ) ;
return {
c ( ) {
create _component ( episodelist . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( episodelist , target , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
const episodelist _changes = { } ;
if ( dirty & 8 )
episodelist _changes . episodes = ctx2 [ 3 ] ;
if ( dirty & 6 )
episodelist _changes . showThumbnails = ! ctx2 [ 1 ] || ! ctx2 [ 2 ] ;
if ( dirty & 67108910 ) {
episodelist _changes . $$scope = { dirty , ctx : ctx2 } ;
}
episodelist . $set ( episodelist _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( episodelist . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( episodelist . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( episodelist , detaching ) ;
}
} ;
}
function create _if _block9 ( ctx ) {
let episodeplayer ;
let current ;
episodeplayer = new EpisodePlayer _default ( { } ) ;
return {
c ( ) {
create _component ( episodeplayer . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( episodeplayer , target , anchor ) ;
current = true ;
} ,
p : noop ,
i ( local ) {
if ( current )
return ;
transition _in ( episodeplayer . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( episodeplayer . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( episodeplayer , detaching ) ;
}
} ;
}
function create _else _block3 ( ctx ) {
let episodelistheader ;
let current ;
episodelistheader = new EpisodeListHeader _default ( { props : { text : "Latest Episodes" } } ) ;
return {
c ( ) {
create _component ( episodelistheader . $$ . fragment ) ;
} ,
m ( target , anchor ) {
mount _component ( episodelistheader , target , anchor ) ;
current = true ;
} ,
p : noop ,
i ( local ) {
if ( current )
return ;
transition _in ( episodelistheader . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( episodelistheader . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
destroy _component ( episodelistheader , detaching ) ;
}
} ;
}
function create _if _block _3 ( ctx ) {
let span ;
let icon0 ;
let t0 ;
let t1 ;
let div ;
let icon1 ;
let t2 ;
let episodelistheader ;
let current ;
let mounted ;
let dispose ;
icon0 = new Icon _default ( {
props : {
icon : "arrow-left" ,
style : { display : "flex" , "align-items" : "center" } ,
size : 20
}
} ) ;
icon1 = new Icon _default ( {
props : {
icon : ctx [ 2 ] . icon ,
size : 40 ,
clickable : false
}
} ) ;
episodelistheader = new EpisodeListHeader _default ( {
props : { text : ctx [ 2 ] . name }
} ) ;
return {
c ( ) {
span = element ( "span" ) ;
create _component ( icon0 . $$ . fragment ) ;
t0 = text ( " Latest Episodes" ) ;
t1 = space ( ) ;
div = element ( "div" ) ;
create _component ( icon1 . $$ . fragment ) ;
t2 = space ( ) ;
create _component ( episodelistheader . $$ . fragment ) ;
attr ( span , "class" , "go-back svelte-unmvd4" ) ;
set _style ( div , "display" , "flex" ) ;
set _style ( div , "align-items" , "center" ) ;
set _style ( div , "justify-content" , "center" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
mount _component ( icon0 , span , null ) ;
append ( span , t0 ) ;
insert ( target , t1 , anchor ) ;
insert ( target , div , anchor ) ;
mount _component ( icon1 , div , null ) ;
insert ( target , t2 , anchor ) ;
mount _component ( episodelistheader , target , anchor ) ;
current = true ;
if ( ! mounted ) {
dispose = listen ( span , "click" , ctx [ 17 ] ) ;
mounted = true ;
}
} ,
p ( ctx2 , dirty ) {
const icon1 _changes = { } ;
if ( dirty & 4 )
icon1 _changes . icon = ctx2 [ 2 ] . icon ;
icon1 . $set ( icon1 _changes ) ;
const episodelistheader _changes = { } ;
if ( dirty & 4 )
episodelistheader _changes . text = ctx2 [ 2 ] . name ;
episodelistheader . $set ( episodelistheader _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon0 . $$ . fragment , local ) ;
transition _in ( icon1 . $$ . fragment , local ) ;
transition _in ( episodelistheader . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon0 . $$ . fragment , local ) ;
transition _out ( icon1 . $$ . fragment , local ) ;
transition _out ( episodelistheader . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
destroy _component ( icon0 ) ;
if ( detaching )
detach ( t1 ) ;
if ( detaching )
detach ( div ) ;
destroy _component ( icon1 ) ;
if ( detaching )
detach ( t2 ) ;
destroy _component ( episodelistheader , detaching ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function create _if _block _22 ( ctx ) {
let span ;
let icon ;
let t0 ;
let t1 ;
let episodelistheader ;
let current ;
let mounted ;
let dispose ;
icon = new Icon _default ( {
props : {
icon : "arrow-left" ,
style : { display : "flex" , "align-items" : "center" } ,
size : 20
}
} ) ;
episodelistheader = new EpisodeListHeader _default ( {
props : {
text : ctx [ 1 ] . title ,
artworkUrl : ctx [ 1 ] . artworkUrl
}
} ) ;
return {
c ( ) {
span = element ( "span" ) ;
create _component ( icon . $$ . fragment ) ;
t0 = text ( " Latest Episodes" ) ;
t1 = space ( ) ;
create _component ( episodelistheader . $$ . fragment ) ;
attr ( span , "class" , "go-back svelte-unmvd4" ) ;
} ,
m ( target , anchor ) {
insert ( target , span , anchor ) ;
mount _component ( icon , span , null ) ;
append ( span , t0 ) ;
insert ( target , t1 , anchor ) ;
mount _component ( episodelistheader , target , anchor ) ;
current = true ;
if ( ! mounted ) {
dispose = listen ( span , "click" , ctx [ 16 ] ) ;
mounted = true ;
}
} ,
p ( ctx2 , dirty ) {
const episodelistheader _changes = { } ;
if ( dirty & 2 )
episodelistheader _changes . text = ctx2 [ 1 ] . title ;
if ( dirty & 2 )
episodelistheader _changes . artworkUrl = ctx2 [ 1 ] . artworkUrl ;
episodelistheader . $set ( episodelistheader _changes ) ;
} ,
i ( local ) {
if ( current )
return ;
transition _in ( icon . $$ . fragment , local ) ;
transition _in ( episodelistheader . $$ . fragment , local ) ;
current = true ;
} ,
o ( local ) {
transition _out ( icon . $$ . fragment , local ) ;
transition _out ( episodelistheader . $$ . fragment , local ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( span ) ;
destroy _component ( icon ) ;
if ( detaching )
detach ( t1 ) ;
destroy _component ( episodelistheader , detaching ) ;
mounted = false ;
dispose ( ) ;
}
} ;
}
function create _header _slot2 ( ctx ) {
let current _block _type _index ;
let if _block ;
let if _block _anchor ;
let current ;
const if _block _creators = [ create _if _block _22 , create _if _block _3 , create _else _block3 ] ;
const if _blocks = [ ] ;
function select _block _type _1 ( ctx2 , dirty ) {
if ( ctx2 [ 1 ] )
return 0 ;
if ( ctx2 [ 2 ] )
return 1 ;
return 2 ;
}
current _block _type _index = select _block _type _1 ( ctx , - 1 ) ;
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
return {
c ( ) {
if _block . c ( ) ;
if _block _anchor = empty ( ) ;
} ,
m ( target , anchor ) {
if _blocks [ current _block _type _index ] . m ( target , anchor ) ;
insert ( target , if _block _anchor , anchor ) ;
current = true ;
} ,
p ( ctx2 , dirty ) {
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type _1 ( ctx2 , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if _blocks [ current _block _type _index ] . p ( ctx2 , dirty ) ;
} else {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
if _block = if _blocks [ current _block _type _index ] ;
if ( ! if _block ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx2 ) ;
if _block . c ( ) ;
} else {
if _block . p ( ctx2 , dirty ) ;
}
transition _in ( if _block , 1 ) ;
if _block . m ( if _block _anchor . parentNode , if _block _anchor ) ;
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if _blocks [ current _block _type _index ] . d ( detaching ) ;
if ( detaching )
detach ( if _block _anchor ) ;
}
} ;
}
function create _fragment23 ( ctx ) {
let div ;
let topbar ;
let updating _viewState ;
let t ;
let current _block _type _index ;
let if _block ;
let current ;
function topbar _viewState _binding ( value ) {
ctx [ 15 ] ( value ) ;
}
let topbar _props = {
canShowEpisodeList : true ,
canShowPlayer : ! ! ctx [ 6 ]
} ;
if ( ctx [ 8 ] !== void 0 ) {
topbar _props . viewState = ctx [ 8 ] ;
}
topbar = new TopBar _default ( { props : topbar _props } ) ;
binding _callbacks . push ( ( ) => bind ( topbar , "viewState" , topbar _viewState _binding ) ) ;
const if _block _creators = [ create _if _block9 , create _if _block _15 , create _if _block _4 ] ;
const if _blocks = [ ] ;
function select _block _type ( ctx2 , dirty ) {
if ( ctx2 [ 8 ] === 2 /* Player */ )
return 0 ;
if ( ctx2 [ 8 ] === 1 /* EpisodeList */ )
return 1 ;
if ( ctx2 [ 8 ] === 0 /* PodcastGrid */ )
return 2 ;
return - 1 ;
}
if ( ~ ( current _block _type _index = select _block _type ( ctx , - 1 ) ) ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx ) ;
}
return {
c ( ) {
div = element ( "div" ) ;
create _component ( topbar . $$ . fragment ) ;
t = space ( ) ;
if ( if _block )
if _block . c ( ) ;
attr ( div , "class" , "podcast-view svelte-unmvd4" ) ;
} ,
m ( target , anchor ) {
insert ( target , div , anchor ) ;
mount _component ( topbar , div , null ) ;
append ( div , t ) ;
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . m ( div , null ) ;
}
ctx [ 18 ] ( div ) ;
current = true ;
} ,
p ( ctx2 , [ dirty ] ) {
const topbar _changes = { } ;
if ( dirty & 64 )
topbar _changes . canShowPlayer = ! ! ctx2 [ 6 ] ;
if ( ! updating _viewState && dirty & 256 ) {
updating _viewState = true ;
topbar _changes . viewState = ctx2 [ 8 ] ;
add _flush _callback ( ( ) => updating _viewState = false ) ;
}
topbar . $set ( topbar _changes ) ;
let previous _block _index = current _block _type _index ;
current _block _type _index = select _block _type ( ctx2 , dirty ) ;
if ( current _block _type _index === previous _block _index ) {
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . p ( ctx2 , dirty ) ;
}
} else {
if ( if _block ) {
group _outros ( ) ;
transition _out ( if _blocks [ previous _block _index ] , 1 , 1 , ( ) => {
if _blocks [ previous _block _index ] = null ;
} ) ;
check _outros ( ) ;
}
if ( ~ current _block _type _index ) {
if _block = if _blocks [ current _block _type _index ] ;
if ( ! if _block ) {
if _block = if _blocks [ current _block _type _index ] = if _block _creators [ current _block _type _index ] ( ctx2 ) ;
if _block . c ( ) ;
} else {
if _block . p ( ctx2 , dirty ) ;
}
transition _in ( if _block , 1 ) ;
if _block . m ( div , null ) ;
} else {
if _block = null ;
}
}
} ,
i ( local ) {
if ( current )
return ;
transition _in ( topbar . $$ . fragment , local ) ;
transition _in ( if _block ) ;
current = true ;
} ,
o ( local ) {
transition _out ( topbar . $$ . fragment , local ) ;
transition _out ( if _block ) ;
current = false ;
} ,
d ( detaching ) {
if ( detaching )
detach ( div ) ;
destroy _component ( topbar ) ;
if ( ~ current _block _type _index ) {
if _blocks [ current _block _type _index ] . d ( ) ;
}
ctx [ 18 ] ( null ) ;
}
} ;
}
function instance22 ( $$self , $$props , $$invalidate ) {
let $queue ;
let $currentEpisode ;
let $episodeCache ;
let $downloadedEpisodes ;
let $localFiles ;
let $favorites ;
let $podcastView ;
let $viewState ;
component _subscribe ( $$self , queue , ( $$value ) => $$invalidate ( 19 , $queue = $$value ) ) ;
component _subscribe ( $$self , currentEpisode , ( $$value ) => $$invalidate ( 6 , $currentEpisode = $$value ) ) ;
component _subscribe ( $$self , episodeCache , ( $$value ) => $$invalidate ( 20 , $episodeCache = $$value ) ) ;
component _subscribe ( $$self , downloadedEpisodes , ( $$value ) => $$invalidate ( 21 , $downloadedEpisodes = $$value ) ) ;
component _subscribe ( $$self , localFiles , ( $$value ) => $$invalidate ( 22 , $localFiles = $$value ) ) ;
component _subscribe ( $$self , favorites , ( $$value ) => $$invalidate ( 23 , $favorites = $$value ) ) ;
component _subscribe ( $$self , podcastView , ( $$value ) => $$invalidate ( 7 , $podcastView = $$value ) ) ;
component _subscribe ( $$self , viewState , ( $$value ) => $$invalidate ( 8 , $viewState = $$value ) ) ;
let feeds = [ ] ;
let selectedFeed = null ;
let selectedPlaylist = null ;
let displayedEpisodes = [ ] ;
let displayedPlaylists = [ ] ;
let latestEpisodes = [ ] ;
onMount ( ( ) => _ _awaiter ( void 0 , void 0 , void 0 , function * ( ) {
const unsubscribePlaylists = playlists . subscribe ( ( pl ) => {
$$invalidate ( 4 , displayedPlaylists = [ $queue , $favorites , $localFiles , ... Object . values ( pl ) ] ) ;
} ) ;
const unsubscribeSavedFeeds = savedFeeds . subscribe ( ( storeValue ) => {
$$invalidate ( 0 , feeds = Object . values ( storeValue ) ) ;
} ) ;
yield fetchEpisodesInAllFeeds ( feeds ) ;
const unsubscribeEpisodeCache = episodeCache . subscribe ( ( cache ) => {
$$invalidate ( 5 , latestEpisodes = Object . entries ( cache ) . map ( ( [ _ , episodes ] ) => episodes . slice ( 0 , 10 ) ) . flat ( ) . sort ( ( a , b ) => {
if ( a . episodeDate && b . episodeDate )
return Number ( b . episodeDate ) - Number ( a . episodeDate ) ;
return 0 ;
} ) ) ;
} ) ;
if ( ! selectedFeed ) {
$$invalidate ( 3 , displayedEpisodes = latestEpisodes ) ;
}
return ( ) => {
unsubscribeEpisodeCache ( ) ;
unsubscribeSavedFeeds ( ) ;
unsubscribePlaylists ( ) ;
} ;
} ) ) ;
function fetchEpisodes ( feed , useCache = true ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const cachedEpisodesInFeed = $episodeCache [ feed . title ] ;
if ( useCache && cachedEpisodesInFeed && cachedEpisodesInFeed . length > 0 ) {
return cachedEpisodesInFeed ;
}
try {
const episodes = yield new FeedParser ( feed ) . getEpisodes ( feed . url ) ;
episodeCache . update ( ( cache ) => Object . assign ( Object . assign ( { } , cache ) , { [ feed . title ] : episodes } ) ) ;
return episodes ;
} catch ( error ) {
return $downloadedEpisodes [ feed . title ] ;
}
} ) ;
}
function fetchEpisodesInAllFeeds ( feedsToSearch ) {
return Promise . all ( feedsToSearch . map ( ( feed ) => fetchEpisodes ( feed ) ) ) . then ( ( episodes ) => {
return episodes . flat ( ) ;
} ) ;
}
function handleClickPodcast ( event ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const { feed } = event . detail ;
$$invalidate ( 3 , displayedEpisodes = [ ] ) ;
$$invalidate ( 1 , selectedFeed = feed ) ;
$$invalidate ( 3 , displayedEpisodes = yield fetchEpisodes ( feed ) ) ;
viewState . set ( 1 /* EpisodeList */ ) ;
} ) ;
}
function handleClickEpisode ( event ) {
const { episode } = event . detail ;
currentEpisode . set ( episode ) ;
viewState . set ( 2 /* Player */ ) ;
}
function handleContextMenuEpisode ( { detail : { event , episode } } ) {
spawnEpisodeContextMenu ( episode , event ) ;
}
function handleClickRefresh ( ) {
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
if ( ! selectedFeed )
return ;
$$invalidate ( 3 , displayedEpisodes = yield fetchEpisodes ( selectedFeed , false ) ) ;
} ) ;
}
const handleSearch = ( 0 , import _obsidian17 . debounce ) ( ( event ) => {
const { query } = event . detail ;
if ( selectedFeed ) {
const episodesInFeed = $episodeCache [ selectedFeed . title ] ;
$$invalidate ( 3 , displayedEpisodes = searchEpisodes ( query , episodesInFeed ) ) ;
return ;
}
$$invalidate ( 3 , displayedEpisodes = searchEpisodes ( query , latestEpisodes ) ) ;
} , 250 ) ;
function handleClickPlaylist ( event ) {
const { event : clickEvent , playlist } = event . detail ;
if ( playlist . name === $queue . name && $queue . episodes . length > 0 ) {
if ( ! $currentEpisode ) {
currentEpisode . set ( $queue . episodes [ 0 ] ) ;
}
viewState . set ( 2 /* Player */ ) ;
} else {
$$invalidate ( 2 , selectedPlaylist = playlist ) ;
$$invalidate ( 3 , displayedEpisodes = playlist . episodes ) ;
viewState . set ( 1 /* EpisodeList */ ) ;
}
}
function topbar _viewState _binding ( value ) {
$viewState = value ;
viewState . set ( $viewState ) ;
}
const click _handler = ( ) => {
$$invalidate ( 1 , selectedFeed = null ) ;
$$invalidate ( 3 , displayedEpisodes = latestEpisodes ) ;
viewState . set ( 1 /* EpisodeList */ ) ;
} ;
const click _handler _1 = ( ) => {
$$invalidate ( 2 , selectedPlaylist = null ) ;
$$invalidate ( 3 , displayedEpisodes = latestEpisodes ) ;
viewState . set ( 1 /* EpisodeList */ ) ;
} ;
function div _binding ( $$value ) {
binding _callbacks [ $$value ? "unshift" : "push" ] ( ( ) => {
$podcastView = $$value ;
podcastView . set ( $podcastView ) ;
} ) ;
}
return [
feeds ,
selectedFeed ,
selectedPlaylist ,
displayedEpisodes ,
displayedPlaylists ,
latestEpisodes ,
$currentEpisode ,
$podcastView ,
$viewState ,
handleClickPodcast ,
handleClickEpisode ,
handleContextMenuEpisode ,
handleClickRefresh ,
handleSearch ,
handleClickPlaylist ,
topbar _viewState _binding ,
click _handler ,
click _handler _1 ,
div _binding
] ;
}
var PodcastView = class extends SvelteComponent {
constructor ( options ) {
super ( ) ;
init ( this , options , instance22 , create _fragment23 , safe _not _equal , { } , add _css17 ) ;
}
} ;
var PodcastView _default = PodcastView ;
// src/ui/PodcastView/index.ts
var MainView = class extends import _obsidian18 . ItemView {
constructor ( leaf , plugin2 ) {
super ( leaf ) ;
this . plugin = plugin2 ;
}
getViewType ( ) {
return VIEW _TYPE ;
}
getDisplayText ( ) {
return "Podcast Player" ;
}
getIcon ( ) {
return "play-circle" ;
}
onOpen ( ) {
return _ _async ( this , null , function * ( ) {
this . PodcastView = new PodcastView _default ( {
target : this . contentEl
} ) ;
} ) ;
}
onClose ( ) {
return _ _async ( this , null , function * ( ) {
var _a ;
( _a = this . PodcastView ) == null ? void 0 : _a . $destroy ( ) ;
this . contentEl . empty ( ) ;
} ) ;
}
} ;
// src/types/StoreController.ts
var StoreController = class {
constructor ( store ) {
this . store = store ;
}
on ( ) {
this . unsubscribe = this . store . subscribe ( this . onChange . bind ( this ) ) ;
return this ;
}
off ( ) {
this . unsubscribe ( ) ;
return this ;
}
} ;
// src/store_controllers/EpisodeStatusController.ts
var EpisodeStatusController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . playedEpisodes = value ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/SavedFeedsController.ts
var SavedFeedsController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . savedFeeds = value ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/PlaylistController.ts
var PlaylistController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . playlists = value ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/QueueController.ts
var QueueController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . queue = _ _spreadValues ( _ _spreadValues ( { } , value ) , QUEUE _SETTINGS ) ;
this . plugin . saveSettings ( ) ;
}
on ( ) {
this . removeCurrentEpisodeFromQueue ( ) ;
return super . on ( ) ;
}
off ( ) {
this . unsubscribeCurrentEpisode ( ) ;
return super . off ( ) ;
}
removeCurrentEpisodeFromQueue ( ) {
this . unsubscribeCurrentEpisode = currentEpisode . subscribe ( ( episode ) => {
if ( ! episode )
return ;
const queue2 = get _store _value ( this . store ) ;
const episodeIsInQueue = queue2 . episodes . find ( ( e ) => e . title === episode . title ) ;
this . store . update ( ( playlist ) => {
if ( ! episodeIsInQueue )
return playlist ;
playlist . episodes = playlist . episodes . filter ( ( e ) => e . title !== episode . title ) ;
return playlist ;
} ) ;
} ) ;
}
} ;
// src/store_controllers/FavoritesController.ts
var FavoritesController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . favorites = _ _spreadValues ( _ _spreadValues ( { } , value ) , FAVORITES _SETTINGS ) ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/CurrentEpisodeController.ts
var CurrentEpisodeController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . currentEpisode = value ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/DownloadedEpisodesController.ts
var DownloadedEpisodesController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . downloadedEpisodes = value ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/store_controllers/LocalFilesController.ts
var LocalFilesController = class extends StoreController {
constructor ( store , plugin2 ) {
super ( store ) ;
this . plugin = plugin2 ;
}
onChange ( value ) {
this . plugin . settings . localFiles = _ _spreadValues ( _ _spreadValues ( { } , value ) , LOCAL _FILES _SETTINGS ) ;
this . plugin . saveSettings ( ) ;
}
} ;
// src/URIHandler.ts
var import _obsidian19 = require ( "obsidian" ) ;
function podNotesURIHandler ( _0 , _1 ) {
return _ _async ( this , arguments , function * ( { url , episodeName , time } , api ) {
if ( ! url || ! episodeName || ! time ) {
new import _obsidian19 . Notice ( "URL, episode name, and timestamp are required to play an episode" ) ;
return ;
}
const decodedName = episodeName . replace ( /\+/g , " " ) ;
const currentEp = get _store _value ( currentEpisode ) ;
const episodeIsPlaying = ( currentEp == null ? void 0 : currentEp . title ) === decodedName ;
if ( episodeIsPlaying ) {
viewState . set ( 2 /* Player */ ) ;
api . currentTime = parseFloat ( time ) ;
return ;
}
const decodedUrl = url . replace ( /\+/g , " " ) ;
const localFile = app . vault . getAbstractFileByPath ( decodedUrl ) ;
let episode ;
if ( localFile ) {
episode = localFiles . getLocalEpisode ( decodedName ) ;
} else {
const feedparser = new FeedParser ( ) ;
episode = yield feedparser . findItemByTitle ( decodedName , url ) ;
}
if ( ! episode ) {
new import _obsidian19 . Notice ( "Episode not found" ) ;
return ;
}
currentEpisode . set ( episode ) ;
viewState . set ( 2 /* Player */ ) ;
new import _obsidian19 . Notice ( "Episode found, playing now. Please click timestamp again to play at specific time." ) ;
} ) ;
}
// src/getContextMenuHandler.ts
var import _obsidian20 = require ( "obsidian" ) ;
function getContextMenuHandler ( ) {
return this . app . workspace . on ( "file-menu" , ( menu , file ) => {
if ( ! ( file instanceof import _obsidian20 . TFile ) )
return ;
if ( ! file . extension . match ( /mp3|mp4|wma|aac|wav|webm|aac|flac|m4a|/ ) )
return ;
menu . addItem ( ( item ) => item . setIcon ( "play" ) . setTitle ( "Play with PodNotes" ) . onClick ( ( ) => _ _async ( this , null , function * ( ) {
var _a ;
const localEpisode = {
title : file . basename ,
description : "" ,
content : "" ,
podcastName : "local file" ,
url : app . fileManager . generateMarkdownLink ( file , "" ) ,
streamUrl : yield createMediaUrlObjectFromFilePath ( file . path ) ,
episodeDate : new Date ( file . stat . ctime )
} ;
if ( ! downloadedEpisodes . isEpisodeDownloaded ( localEpisode ) ) {
downloadedEpisodes . addEpisode ( localEpisode , file . path , file . stat . size ) ;
localFiles . addEpisode ( localEpisode ) ;
}
if ( ( _a = get _store _value ( playedEpisodes ) [ file . basename ] ) == null ? void 0 : _a . finished ) {
playedEpisodes . markAsUnplayed ( localEpisode ) ;
}
currentEpisode . set ( localEpisode ) ;
viewState . set ( 2 /* Player */ ) ;
} ) ) ) ;
} ) ;
}
// src/getUniversalPodcastLink.ts
var import _obsidian21 = require ( "obsidian" ) ;
function getUniversalPodcastLink ( api ) {
return _ _async ( this , null , function * ( ) {
const { title , itunesTitle , podcastName , feedUrl } = api . podcast ;
try {
const iTunesResponse = yield queryiTunesPodcasts ( api . podcast . podcastName ) ;
const podcast = iTunesResponse . find ( ( pod ) => pod . title === podcastName && pod . url === feedUrl ) ;
if ( ! podcast || ! podcast . collectionId ) {
throw new Error ( "Failed to get podcast from iTunes." ) ;
}
const podLinkUrl = ` https://pod.link/ ${ podcast . collectionId } .json?limit=1000 ` ;
const res = yield ( 0 , import _obsidian21 . requestUrl ) ( {
url : podLinkUrl
} ) ;
if ( res . status !== 200 ) {
throw new Error ( ` Failed to get response from pod.link: ${ podLinkUrl } ` ) ;
}
const targetTitle = itunesTitle != null ? itunesTitle : title ;
const ep = res . json . episodes . find ( ( episode ) => episode . title === targetTitle ) ;
if ( ! ep ) {
throw new Error ( ` Failed to find episode " ${ targetTitle } " on pod.link. URL: ${ podLinkUrl } ` ) ;
}
window . navigator . clipboard . writeText ( ` https://pod.link/ ${ podcast . collectionId } /episode/ ${ ep . episodeId } ` ) ;
new import _obsidian21 . Notice ( "Universal episode link copied to clipboard." ) ;
} catch ( error ) {
new import _obsidian21 . Notice ( "Could not get podcast link." ) ;
console . error ( error ) ;
return ;
}
} ) ;
}
// src/main.ts
var PodNotes = class extends import _obsidian22 . Plugin {
onload ( ) {
return _ _async ( this , null , function * ( ) {
plugin . set ( this ) ;
yield this . loadSettings ( ) ;
playedEpisodes . set ( this . settings . playedEpisodes ) ;
savedFeeds . set ( this . settings . savedFeeds ) ;
playlists . set ( this . settings . playlists ) ;
queue . set ( this . settings . queue ) ;
favorites . set ( this . settings . favorites ) ;
localFiles . set ( this . settings . localFiles ) ;
downloadedEpisodes . set ( this . settings . downloadedEpisodes ) ;
if ( this . settings . currentEpisode ) {
currentEpisode . set ( this . settings . currentEpisode ) ;
}
this . playedEpisodeController = new EpisodeStatusController ( playedEpisodes , this ) . on ( ) ;
this . savedFeedsController = new SavedFeedsController ( savedFeeds , this ) . on ( ) ;
this . playlistController = new PlaylistController ( playlists , this ) . on ( ) ;
this . queueController = new QueueController ( queue , this ) . on ( ) ;
this . favoritesController = new FavoritesController ( favorites , this ) . on ( ) ;
this . localFilesController = new LocalFilesController ( localFiles , this ) . on ( ) ;
this . downloadedEpisodesController = new DownloadedEpisodesController ( downloadedEpisodes , this ) . on ( ) ;
this . currentEpisodeController = new CurrentEpisodeController ( currentEpisode , this ) . on ( ) ;
this . addCommand ( {
id : "podnotes-show-leaf" ,
name : "Show PodNotes" ,
icon : "podcast" ,
checkCallback ( checking ) {
if ( checking ) {
return ! app . workspace . getLeavesOfType ( VIEW _TYPE ) . length ;
}
app . workspace . getRightLeaf ( false ) . setViewState ( {
type : VIEW _TYPE
} ) ;
}
} ) ;
this . addCommand ( {
id : "start-playing" ,
name : "Play Podcast" ,
icon : "play-circle" ,
checkCallback : ( checking ) => {
if ( checking ) {
return ! this . api . isPlaying && ! ! this . api . podcast ;
}
this . api . start ( ) ;
}
} ) ;
this . addCommand ( {
id : "stop-playing" ,
name : "Stop Podcast" ,
icon : "stop-circle" ,
checkCallback : ( checking ) => {
if ( checking ) {
return this . api . isPlaying && ! ! this . api . podcast ;
}
this . api . stop ( ) ;
}
} ) ;
this . addCommand ( {
id : "skip-backward" ,
name : "Skip Backward" ,
icon : "skip-back" ,
checkCallback : ( checking ) => {
if ( checking ) {
return this . api . isPlaying && ! ! this . api . podcast ;
}
this . api . skipBackward ( ) ;
}
} ) ;
this . addCommand ( {
id : "skip-forward" ,
name : "Skip Forward" ,
icon : "skip-forward" ,
checkCallback : ( checking ) => {
if ( checking ) {
return this . api . isPlaying && ! ! this . api . podcast ;
}
this . api . skipForward ( ) ;
}
} ) ;
this . addCommand ( {
id : "download-playing-episode" ,
name : "Download Playing Episode" ,
icon : "download" ,
checkCallback : ( checking ) => {
if ( checking ) {
return ! ! this . api . podcast ;
}
const episode = this . api . podcast ;
downloadEpisodeWithNotice ( episode , this . settings . download . path ) ;
}
} ) ;
this . addCommand ( {
id : "hrpn" ,
name : "Reload PodNotes" ,
callback : ( ) => {
const id = this . manifest . id ;
this . app . plugins . disablePlugin ( id ) . then ( ( ) => this . app . plugins . enablePlugin ( id ) ) ;
}
} ) ;
this . addCommand ( {
id : "capture-timestamp" ,
name : "Capture Timestamp" ,
icon : "clock" ,
editorCheckCallback : ( checking , editor , view ) => {
if ( checking ) {
return ! ! this . api . podcast && ! ! this . settings . timestamp . template ;
}
const cursorPos = editor . getCursor ( ) ;
const capture = TimestampTemplateEngine ( this . settings . timestamp . template ) ;
editor . replaceRange ( capture , cursorPos ) ;
editor . setCursor ( cursorPos . line , cursorPos . ch + capture . length ) ;
}
} ) ;
this . addCommand ( {
id : "create-podcast-note" ,
name : "Create Podcast Note" ,
icon : "file-plus" ,
checkCallback : ( checking ) => {
if ( checking ) {
return ! ! this . api . podcast && ! ! this . settings . note . path && ! ! this . settings . note . template ;
}
createPodcastNote ( this . api . podcast ) ;
}
} ) ;
this . addCommand ( {
id : "get-share-link-episode" ,
name : "Copy universal episode link to clipboard" ,
icon : "share" ,
checkCallback : ( checking ) => {
if ( checking ) {
return ! ! this . api . podcast ;
}
getUniversalPodcastLink ( this . api ) ;
}
} ) ;
this . addCommand ( {
id : "podnotes-toggle-playback" ,
name : "Toggle playback" ,
icon : "play" ,
checkCallback : ( checking ) => {
if ( checking ) {
return ! ! this . api . podcast ;
}
this . api . togglePlayback ( ) ;
}
} ) ;
this . addSettingTab ( new PodNotesSettingsTab ( this . app , this ) ) ;
this . registerView ( VIEW _TYPE , ( leaf ) => {
this . view = new MainView ( leaf , this ) ;
this . api = new API ( ) ;
return this . view ;
} ) ;
this . app . workspace . onLayoutReady ( this . onLayoutReady . bind ( this ) ) ;
this . registerObsidianProtocolHandler ( "podnotes" , ( action ) => podNotesURIHandler ( action , this . api ) ) ;
this . registerEvent ( getContextMenuHandler ( ) ) ;
} ) ;
}
onLayoutReady ( ) {
if ( this . app . workspace . getLeavesOfType ( VIEW _TYPE ) . length ) {
return ;
}
this . app . workspace . getRightLeaf ( false ) . setViewState ( {
type : VIEW _TYPE
} ) ;
}
onunload ( ) {
this == null ? void 0 : this . playedEpisodeController . off ( ) ;
this == null ? void 0 : this . savedFeedsController . off ( ) ;
this == null ? void 0 : this . playlistController . off ( ) ;
this == null ? void 0 : this . queueController . off ( ) ;
this == null ? void 0 : this . favoritesController . off ( ) ;
this == null ? void 0 : this . localFilesController . off ( ) ;
this == null ? void 0 : this . downloadedEpisodesController . off ( ) ;
this == null ? void 0 : this . currentEpisodeController . off ( ) ;
}
loadSettings ( ) {
return _ _async ( this , null , function * ( ) {
this . settings = Object . assign ( { } , DEFAULT _SETTINGS , yield this . loadData ( ) ) ;
} ) ;
}
saveSettings ( ) {
return _ _async ( this , null , function * ( ) {
yield this . saveData ( this . settings ) ;
} ) ;
}
} ;