jQuery(function(e){var t={};if(e("#cache_assets").length>0){e("#cache_assets").html("");var r,a={name:"pwa.cache.assets",mode:"code",modes:["code","tree"],onError:function(e){console.error("JSON",e.toString()),alert("JSON error. Please verify your input.\n\nSee console for details.")},onChange:function(){var a=t.assetpolicy.getText();if(""===e.trim(a))return r&&clearTimeout(r),void(r=setTimeout(function(){r=!1;var a=t.assetpolicy.getText();""===e.trim(a)&&(t.assetpolicy.set({}),jQuery("#cache_assets_src").val("{}"))},25));try{var n=t.assetpolicy.get()}catch(e){return}jQuery("#cache_assets_src").val(JSON.stringify(n))},onModeChange:function(r,a){var n=t.assetpolicy.getText();""===e.trim(n)&&t.assetpolicy.set({}),"tree"===r||e("#cache_assets_src").data("json-editor").editor.setOptions({maxLines:50})},search:!1,schema:{title:"PWA Cache Policy",type:"array",items:{type:"object",properties:{title:{type:"string"},match:{type:"array",items:{oneOf:[{title:"Match the URL of an asset.",type:"object",properties:{type:{type:"string",enum:["url"]},pattern:{type:"string",minLength:1},regex:{type:"boolean"},not:{type:"boolean"}},required:["type","pattern"],additionalProperties:!1},{title:"Match the URL of an asset in a list of URLs.",type:"object",properties:{type:{type:"string",enum:["url"]},pattern:{type:"array",items:{type:"string",minLength:1},uniqueItems:!0},not:{type:"boolean"}},required:["type","pattern"],additionalProperties:!1},{title:"Match a request header.",type:"object",properties:{type:{type:"string",enum:["header"]},name:{type:"string",minLength:1},pattern:{type:"string",minLength:1},regex:{type:"boolean"},not:{type:"boolean"}},required:["type","name","pattern"],additionalProperties:!1}]},uniqueItems:!0},strategy:{title:"Enter the cache strategy for the matched resources.",type:"string",default:"network",enum:["never","cache","network","event"]},offline:{title:"Enter a path to an alternative resource to precache and serve when the network fails and no cache is available.",type:"string"},cache:{title:"Cache configuration",type:"object",properties:{update_interval:{title:"Enter a time in seconds to update the cache.",type:"number",min:0},head_update:{title:"Update cache ased on HTTP HEAD request with etag/last-modified header validation.",type:"boolean"},max_age:{title:"Enter an expire time in seconds.",type:"number",min:0},conditions:{type:"array",items:{oneOf:[{title:"Match the URL of an asset.",type:"object",properties:{type:{type:"string",enum:["url"]},pattern:{type:"string",minLength:1},regex:{type:"boolean"},not:{type:"boolean"}},required:["type","pattern"],additionalProperties:!1},{title:"Match a response header.",type:"object",properties:{type:{type:"string",enum:["header"]},name:{type:"string",minLength:1},pattern:{type:"string",minLength:1},regex:{type:"boolean"},not:{type:"boolean"}},required:["type","name","pattern"],additionalProperties:!1},{title:"Match a response header by comparison.",type:"object",properties:{type:{type:"string",enum:["header"]},name:{type:"string",minLength:1},pattern:{oneOf:[{title:"Compare a numeric header value.",type:"object",properties:{operator:{type:"string",enum:["<","=",">"]},value:{type:"number"}},additionalProperties:!1}]},not:{type:"boolean"}},required:["type","name","pattern"],additionalProperties:!1}]},uniqueItems:!0}},required:[],additionalProperties:!1}},additionalProperties:!1,required:["match","strategy"]},uniqueItems:!0}},n={};if(""!==jQuery("#cache_assets_src").val()){if("object"!=typeof(n=jQuery("#cache_assets_src").val()))try{n=JSON.parse(n)}catch(e){n={}}n&&"object"==typeof n||(n={})}n instanceof Array&&0===n.length&&(n={});s=!1;"{}"===JSON.stringify(n)&&(s=!0),t.assetpolicy=new JSONEditor(e("#cache_assets")[0],a,n),"code"===a.mode&&(s||t.assetpolicy.editor.setOptions({maxLines:50})),e("#cache_assets_src").data("json-editor",t.assetpolicy)}if(e("#webapp_manifest").length>0){e("#webapp_manifest").html("");var i,a={name:"pwa.manifest",mode:"tree",modes:["code","tree"],onError:function(e){console.error("JSON",e.toString()),alert("JSON error. Please verify your input.\n\nSee console for details.")},onChange:function(){var r=t.manifest.getText();if(""===e.trim(r))return i&&clearTimeout(i),void(i=setTimeout(function(){i=!1;var r=t.manifest.getText();""===e.trim(r)&&(t.manifest.set({}),jQuery("#webapp_manifest_src").val("{}"))},25));try{var a=t.manifest.get()}catch(e){return}jQuery("#webapp_manifest_src").val(JSON.stringify(a))},onModeChange:function(r,a){var n=t.manifest.getText();""===e.trim(n)&&t.manifest.set({})},search:!1,schema:{title:"Web App Manifest",type:"object",properties:{short_name:{type:"string"},name:{type:"string"},theme_color:{type:"string"},background_color:{type:"string"},display:{type:"string",enum:["fullscreen","standalone","minimal-ui","browser"]},orientation:{type:"string",enum:["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"]},start_url:{type:"string"},lang:{type:"string"},dir:{type:"string"},scope:{type:"string"},serviceworker:{type:"object",properties:{src:{type:"string"},scope:{type:"string"},use_cache:{type:"boolean"}},additionalProperties:!0},related_applications:{type:"array",items:{type:"object",properties:{platform:{type:"string"},url:{type:"string"},id:{type:"string"}},additionalProperties:!0},uniqueItems:!0},icons:{type:"array",items:{type:"object",properties:{src:{type:"string"},type:{type:"string"},sizes:{type:"string"},density:{type:"string"}},additionalProperties:!0},uniqueItems:!0},screenshots:{type:"array",items:{type:"object",properties:{src:{type:"string"},type:{type:"string"},sizes:{type:"string"}},additionalProperties:!0},uniqueItems:!0}},required:["name","short_name","icons","theme_color","background_color","display","orientation","start_url"],additionalProperties:!0}},n={};if(""!==jQuery("#webapp_manifest_src").val()){if("object"!=typeof(n=jQuery("#webapp_manifest_src").val()))try{n=JSON.parse(n)}catch(e){n={}}n&&"object"==typeof n||(n={})}n instanceof Array&&0===n.length&&(n={});var s=!1;"{}"===JSON.stringify(n)&&(s=!0,a.mode="code"),t.manifest=new JSONEditor(e("#webapp_manifest")[0],a,n),a.mode,e("#webapp_manifest_src").data("json-editor",t.manifest)}if(jQuery("#offline_page").length>0)jQuery("#offline_page").selectize({options:[],searchField:["name","value"],persist:!0,maxItem:1,placeholder:"Enter a URL or absolute path, e.g. /offline/",delimiter:"|==abtf==|",render:{option:function(e,t){return'
'+t(e.name)+"
"},item:function(e,t){return'
'+t(e.name)+"
"}},create:function(e){return{value:e,name:e}},load:function(e,t){if(!e.length)return t();jQuery.ajax({url:ajaxurl,type:"POST",dataType:"json",data:{action:"abtf_page_search",query:e,maxresults:10},error:function(){t()},success:function(e){if(e&&document.location.host)for(var r=e.length,a=0;a