import{aq as p}from"./Commands.539ca0ee.js";import{P as h,am as d,ai as y}from"./index.b7741aa8.js";import{w as S}from"./index.d3776286.js";function u(n){return!!(n&&typeof n=="object"&&!Array.isArray(n))}function a(n,...t){if(!t.length)return n;const i=t.shift();if(u(n)&&u(i))for(const s in i){const e=n[s],o=i[s];u(o)&&u(e)?(e||Object.assign(n,{[s]:{}}),a(e,o)):e||Object.assign(n,{[s]:o})}return a(n,...t)}const c="URL_HASH_CONTEXT";function k(){const{subscribe:n,update:t}=S({hash:"",page:null,identifier:null,hashState:null});return{subscribe:n,setHash(i,s){t(e=>{const[o,...r]=s.slice(1).split("&");return e.page=i,e.hash=s,e.identifier=o,e.hashState=r.join("&"),e})}}}function b(n,t){const i=`#${n}`+(t!=""?`&${t}`:"");i!=location.hash&&history.pushState(null,"",i)}function J(n){h(c,n)}function N(){if(!d(c))throw new Error("UrlHashStoreContext not found");return y(c)}function l(n,t){const i=Object.keys(n);for(const s of i){const e=n[s],o=t[s],r=JSON.stringify(e),f=JSON.stringify(o);r==f&&delete n[s],typeof e=="object"&&o!=null&&e!=null&&l(e,o)}}function O(n,t){n=JSON.parse(JSON.stringify(n)),l(n,t);const i=[];for(const s of Object.keys(n)){const e=JSON.stringify(n[s]);i.push([s,e])}return i.map(([s,e])=>`${s}=${encodeURIComponent(e)}`).join("&")}function U(n,t){if(t=JSON.parse(JSON.stringify(t)),n==null||n=="")return t;const i={},s=(decodeURIComponent(n)||"").split("&");for(const e of s){if(e==null)continue;const[o,r]=e.split("=");i[o]=JSON.parse(r)}return a(t,i)}function H(n,t,i,s,e,o){let r=!1;s.subscribe(f=>{f.page===n&&f.identifier===t&&(r=!0,i.set(e(f.hashState)))}),i.subscribe(f=>{f!=null&&(r||b(t,o(f)),r=!1)})}function x(n){return n!=null}function $(n,t){return`${n}/${t}`}function V(n,t){return`/concepts#${$(n,t)}`}function j(n,t){return`${n}/${t}`}function L(n,t,i){let s=null;if(i!=null){const e=p(n,t);s=O(i,e)}return`/datasets#${j(n,t)}${s!=null?`&${s}`:""}`}function w(n){return`/signals#${n}`}export{J as a,k as b,V as c,$ as d,j as e,L as f,N as g,O as h,U as i,x as n,H as p,w as s};
