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