window.wp=window.wp||{},function(a){"use strict";var b={},c={},d=wp.media,e=["encodedText"];wp.mce=wp.mce||{},wp.mce.View=function(a){a=a||{},this.type=a.type,_.extend(this,_.pick(a,e)),this.initialize.apply(this,arguments)},_.extend(wp.mce.View.prototype,{initialize:function(){},getHtml:function(){return""},loadingPlaceholder:function(){return'
',function(b,c,d){a(b).trigger("ready",[c,d])},"wrap")},unbind:function(){},setContent:function(b,c,d){_.each(tinymce.editors,function(e){var f=this;e.plugins.wpview&&a(e.getBody()).find('[data-wpview-text="'+this.encodedText+'"]').each(function(g,h){var i=a(h).find(".wpview-content"),j=h;i.length&&"wrap"!==d&&(h=i=i[0]),_.isString(b)?"replace"===d?h=e.dom.replace(e.dom.createFragment(b),j):e.dom.setHTML(h,b):"replace"===d?h=e.dom.replace(b,j):a(h).empty().append(b),_.isFunction(c)&&c(f,e,a(h).find(".wpview-content")[0])})},this)},setError:function(a,b){this.setContent('
'+a+"
"+e.find("source").eq(0).prop("src")+"
"))},getHtml:function(){var a=this.shortcode.attrs.named;return a.content=this.shortcode.content,this.template({model:_.defaults(a,wp.media[this.shortcode.tag].defaults)})},unbind:function(){this.unsetPlayers()}}),edit:function(b){var c,d,e,f=wp.media[this.type],g=this;a(document).trigger("media:edit"),d=window.decodeURIComponent(a(b).attr("data-wpview-text")),c=f.edit(d),c.on("close",function(){c.detach()}),e=function(d){var e=wp.media[g.type].shortcode(d).string();a(b).attr("data-wpview-text",window.encodeURIComponent(e)),wp.mce.views.refreshView(g,e),c.detach()},_.isArray(g.state)?_.each(g.state,function(a){c.state(a).on("update",e)}):c.state(g.state).on("update",e),c.open()}},wp.mce.views.register("video",_.extend({},wp.mce.av,{state:"video-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-video")})})),wp.mce.views.register("audio",_.extend({},wp.mce.av,{state:"audio-details",View:_.extend({},wp.mce.av.View,{template:d.template("editor-audio")})})),wp.mce.views.register("playlist",_.extend({},wp.mce.av,{state:["playlist-edit","video-playlist-edit"],View:_.extend({},wp.media.mixin,{template:d.template("editor-playlist"),overlay:!0,initialize:function(b){this.players=[],this.data={},this.attachments=[],this.shortcode=b.shortcode,a(this).on("ready",function(a,b){b.on("hide",this.pausePlayers)}),a(document).on("media:edit",this.pausePlayers),this.fetch(),a(this).on("ready",this.setPlaylist)},fetch:function(){this.attachments=wp.media.playlist.attachments(this.shortcode),this.dfd=this.attachments.more().done(_.bind(this.render,this))},setPlaylist:function(b,c,d){this.data.tracks&&this.players.push(new WPPlaylistView({el:a(d).find(".wp-playlist").get(0),metadata:this.data}).player)},getHtml:function(){var a,b,c=this.shortcode.attrs.named,e=wp.media.playlist,f=[];return this.dfd&&"pending"===this.dfd.state()&&!this.attachments.length?"":(_.each(e.defaults,function(a,b){c[b]=e.coerce(c,b)}),a={type:c.type,style:c.style,tracklist:c.tracklist,tracknumbers:c.tracknumbers,images:c.images,artists:c.artists},this.attachments.length?(b=this.attachments.toJSON(),_.each(b,function(b){var e={},g={},h={src:b.url,type:b.mime,title:b.title,caption:b.caption,description:b.description,meta:b.meta};"video"===c.type?(e.width=b.width,e.height=b.height,d.view.settings.contentWidth?(g.width=d.view.settings.contentWidth-22,g.height=Math.ceil(e.height*g.width/e.width),a.width||(a.width=g.width,a.height=g.height)):a.width||(a.width=b.width,a.height=b.height),h.dimensions={original:e,resized:_.isEmpty(g)?e:g}):a.width=400,h.image=b.image,h.thumb=b.thumb,f.push(h)}),a.tracks=f,this.data=a,this.template(a)):this.template(a))},unbind:function(){this.unsetPlayers()}})})),wp.mce.embedView=_.extend({},wp.media.mixin,{overlay:!0,initialize:function(b){this.players=[],this.content=b.content,this.fetching=!1,this.parsed=!1,this.original=b.url||b.shortcode.string(),this.shortcode=b.url?"[embed]"+b.url+"[/embed]":b.shortcode.string(),_.bindAll(this,"setHtml","setNode","fetch"),a(this).on("ready",this.setNode)},unbind:function(){var a=this;_.each(this.players,function(b){b.pause(),a.removePlayer(b)}),this.players=[]},setNode:function(){this.parsed?(this.setHtml(this.parsed),this.parseMediaShortcodes()):this.fetching||this.fetch()},fetch:function(){var b=this;this.fetching=!0,wp.ajax.send("parse-embed",{data:{post_ID:a("#post_ID").val()||0,shortcode:this.shortcode}}).always(function(){b.fetching=!1}).done(function(a){a&&(b.parsed=a,b.setHtml(a))}).fail(function(a){a&&a.message?"not-embeddable"===a.type&&"embed"===b.type||"not-ssl"===a.type?b.setError(a.message,"admin-media"):b.setContent(""+b.original+"
",null,"replace"):a&&a.statusText&&b.setError(a.statusText,"admin-media")})},setHtml:function(b){var c,d,e,f,g=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,h=tinymce.DOM;if(-1!==b.indexOf("