"use strict";(self.webpackChunka_jupyterlite_query_config=self.webpackChunka_jupyterlite_query_config||[]).push([[509],{509:(e,r,t)=>{t.r(r),t.d(r,{default:()=>i});var o=t(842);const n="a-jupyterlite-query-config:plugin",i={id:n,autoStart:!0,requires:[],activate:e=>{console.log("JupyterLite extension a-jupyterlite-query-config is activated!");const r=(JSON.parse(o.PageConfig.getOption("litePluginSettings")||"{}")[n]||{}).overrides||{},t=new URL(window.location.href).searchParams;function i(e,r){if(null===r||"string"==typeof r||"number"==typeof r||"boolean"==typeof r)return r;if(Array.isArray(r))return r.map(((r,t)=>i(Array.isArray(e)?e[t]:void 0,r)));const t="$conat";if(Object.prototype.hasOwnProperty.call(r,t)){if(1!==Object.keys(r).length)throw new SyntaxError(`${t} must be the only key`);if(r=r[t],!Array.isArray(e)||!Array.isArray(r))throw new TypeError(`can only ${t} two arrays`);return[...e,r.map((e=>i(void 0,e)))]}const o="$override";if(Object.prototype.hasOwnProperty.call(r,o)){if(1!==Object.keys(r).length)throw new SyntaxError(`${o} must be the only key`);if(r=r[o],null===e||"object"!=typeof e||Array.isArray(e)||null===r||"object"!=typeof r||Array.isArray(r))throw new TypeError(`can only ${o} one object with another object`);return{...e,...Object.entries(r).reduce(((e,[r,t])=>(e[r]=i(void 0,t),e)),{})}}return Object.entries(r).reduce(((r,[t,o])=>{if(t.startsWith("$"))throw new SyntaxError(`unknown merge operator '${t}'`);return r[t]=i(null===e||"object"!=typeof e||Array.isArray(e)?void 0:e[t],o),r}),{})}for(const[e,n]of Object.entries(r)){const r=t.get(e);if(null===r)continue;const a=JSON.parse(r),[y,...s]=n.split("."),c=o.PageConfig.getOption(y),l=""===c?{}:JSON.parse(c);if(0===s.length){try{o.PageConfig.setOption(y,JSON.stringify(i(l,a)))}catch(e){console.error(`failed to apply JupyterLite query config '${y}'=${a}: ${e}`)}continue}let u=l;for(const[e,r]of s.entries())if(e<s.length-1)void 0===u[r]&&(u[r]={}),u=u[r];else try{u[r]=i(u[r],a)}catch(e){console.error(`failed to apply JupyterLite query config '${y}'=${a}: ${e}`)}o.PageConfig.setOption(y,JSON.stringify(l))}}}}}]);