1import{t as e}from"./BGze3w87.js";var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},r=n({fromString:()=>f,get:()=>u,isIndexSegment:()=>s,isIndexTuple:()=>l,isKeySegment:()=>c,reKeySegment:()=>a,toString:()=>d}),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,a=/_key\s*==\s*['"](.*)['"]/,o=/^\d*:\d*$/;function s(e){return typeof e==`number`||typeof e==`string`&&/^\[\d+\]$/.test(e)}function c(e){return typeof e==`string`?a.test(e.trim()):typeof e==`object`&&`_key`in e}function l(e){if(typeof e==`string`&&o.test(e))return!0;if(!Array.isArray(e)||e.length!==2)return!1;let[t,n]=e;return(typeof t==`number`||t===``)&&(typeof n==`number`||n===``)}function u(e,t,n){let r=typeof t==`string`?f(t):t;if(!Array.isArray(r))throw Error(`Path must be an array or a string`);let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(s(t)){if(!Array.isArray(i))return n;i=i[t]}if(c(t)){if(!Array.isArray(i))return n;i=i.find(e=>e._key===t._key)}if(typeof t==`string`&&(i=typeof i==`object`&&i?i[t]:void 0),i===void 0)return n}return i}function d(e){if(!Array.isArray(e))throw Error(`Path is not an array`);return e.reduce((e,t,n)=>{let r=typeof t;if(r===`number`)return`${e}[${t}]`;if(r===`string`)return`${e}${n===0?``:`.`}${t}`;if(c(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){let[n,r]=t;return`${e}[${n}:${r}]`}throw Error(`Unsupported path segment \`${JSON.stringify(t)}\``)},``)}function f(e){if(typeof e!=`string`)throw Error(`Path is not a string`);let t=e.match(i);if(!t)throw Error(`Invalid path string`);return t.map(p)}function p(e){return s(e)?m(e):c(e)?h(e):l(e)?g(e):e}function m(e){return Number(e.replace(/[^\d]/g,``))}function h(e){return{_key:e.match(a)[1]}}function g(e){let[t,n]=e.split(`:`).map(e=>e===``?e:Number(e));return[t,n]}var _=`drafts`,v=`versions`,y=`${_}.`,b=`${v}.`;function x(e){return e.startsWith(y)}function S(e){return e.startsWith(b)}function C(e){return!x(e)&&!S(e)}function w(e){return e}function T(e){return e}function E(e){return S(e)?w(y+k(e)):x(e)?e:y+e}function D(e,t){if(t===`drafts`||t===`published`)throw Error(`Version can not be "published" or "drafts"`);return`${b}${t}.${k(e)}`}function O(e){if(!S(e))return;let[t,n,...r]=e.split(`.`);return n}function k(e){if(S(e))return T(e.split(`.`).slice(2).join(`.`));if(x(e))return T(e.slice(y.length));if(C(e))return e;throw Error(`Unable to resolve a published id from "${e}"`)}var A={"\f":`\\f`,"\n":`\\n`,"\r":`\\r`," ":`\\t`,"'":`\\'`,"\\":`\\\\`},j={"\\f":`\f`,"\\n":` 2`,"\\r":`\r`,"\\t":` `,"\\'":`'`,"\\\\":`\\`};function M(e){return`$${e.map(e=>typeof e==`string`?`['${e.replace(/[\f\n\r\t'\\]/g,e=>A[e])}']`:typeof e==`number`?`[${e}]`:e._key===``?`[${e._index}]`:`[?(@._key=='${e._key.replace(/['\\]/g,e=>A[e])}')]`).join(``)}`}function N(e){return e.map(e=>typeof e==`string`?`['${e.replace(/[\f\n\r\t'\\]/g,e=>A[e])}']`:typeof e==`number`?`[${e}]`:e._key===``?`[${e._index}]`:`[?(@._key=='${e._key.replace(/['\\]/g,e=>A[e])}')]`)}function P(e){let t=[],n=/\['(.*?)'\]|\[(\d+)\]|\[\?\(@\._key=='(.*?)'\)\]/g,r;for(;(r=n.exec(e))!==null;){if(r[1]!==void 0){let e=r[1].replace(/\\(\\|f|n|r|t|')/g,e=>j[e]);t.push(e);continue}if(r[2]!==void 0){t.push(parseInt(r[2],10));continue}if(r[3]!==void 0){let e=r[3].replace(/\\(\\')/g,e=>j[e]);t.push({_key:e,_index:-1});continue}}return t}function F(e){return e.map(e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e._key!==``)return{_key:e._key};if(e._index!==-1)return e._index;throw Error(`invalid segment:${JSON.stringify(e)}`)})}function I(e){return(typeof e==`string`?f(e):e).map(e=>{if(typeof e==`string`||typeof e==`number`)return e;if(Array.isArray(e))throw Error(`IndexTuple segments aren't supported:${JSON.stringify(e)}`);if(L(e))return e;if(e._key)return{_key:e._key,_index:-1};throw Error(`invalid segment:${JSON.stringify(e)}`)})}function L(e){return typeof e==`object`&&`_key`in e&&`_index`in e}function R(e){return e.map(e=>{if(typeof e==`string`||typeof e==`number`)return e;if(e._index!==-1)return e._index;throw Error(`invalid segment:${JSON.stringify(e)}`)})}function z(e,t){if(!t?.mappings)return;let n=M(R(e));if(t.mappings[n]!==void 0)return{mapping:t.mappings[n],matchedPath:n,pathSuffix:``};let r=N(R(e));for(let e=r.length-1;e>=0;e--){let i=`$${r.slice(0,e).join(``)}`,a=t.mappings[i];if(a)return{mapping:a,matchedPath:i,pathSuffix:n.substring(i.length)}}}function B(e){return e!==null&&Array.isArray(e)}function V(t,n,r=[]){if(B(t))return t.map((t,i)=>{if(e(t)){let e=t._key;if(typeof e==`string`)return V(t,n,r.concat({_key:e,_index:i}))}return V(t,n,r.concat(i))});if(e(t)){if(t._type===`block`||t._type===`span`){let e={...t};return t._type===`block`?e.children=V(t.children,n,r.concat(`children`)):t._type===`span`&&(e.text=V(t.text,n,r.concat(`text`))),e}return Object.fromEntries(Object.entries(t).map(([e,t])=>[e,V(t,n,r.concat(e))]))}return n(t,r)}function H(e){let{baseUrl:t,workspace:n=`default`,tool:r=`default`,id:i,type:a,path:o,projectId:s,dataset:c}=e;if(!t)throw Error(`baseUrl is required`);if(!o)throw Error(`path is required`);if(!i)throw Error(`id is required`);if(t!==`/`&&t.endsWith(`/`))throw Error(`baseUrl must not end with a slash`);let l=n==="default"?void 0:n,u=r==="default"?void 0:r,f=k(i),p=Array.isArray(o)?d(F(o)):o,m=new URLSearchParams({baseUrl:t,id:f,type:a,path:p});if(l&&m.set(`workspace`,l),u&&m.set(`tool`,u),s&&m.set(`projectId`,s),c&&m.set(`dataset`,c),C(i))m.set(`perspective`,`published`);else if(S(i)){let e=O(i);
2m.set(`perspective`,e)}let h=[t===`/`?``:t];l&&h.push(l);let g=[`mode=presentation`,`id=${f}`,`type=${a}`,`path=${encodeURIComponent(p)}`];return u&&g.push(`tool=${u}`),h.push(`intent`,`edit`,`${g.join(`;`)}?${m}`),h.join(`/`)}function U(e){let{resultSourceMap:t,resultPath:n}=e,{mapping:r,pathSuffix:i}=z(n,t)||{};if(!r||r.source.type===`literal`||r.source.type===`unknown`)return;let a=t.documents[r.source.document],o=t.paths[r.source.path];if(a&&o){let{baseUrl:t,workspace:n,tool:r}=W(typeof e.studioUrl==`function`?e.studioUrl(a):e.studioUrl);if(!t)return;let{_id:s,_type:c,_projectId:l,_dataset:u}=a;return{baseUrl:t,workspace:n,tool:r,id:s,type:c,path:P(o+i),projectId:l,dataset:u}}}function W(e){let t=typeof e==`string`?e:e.baseUrl;return t!==`/`&&(t=t.replace(/\/$/,``)),typeof e==`string`?{baseUrl:t}:{...e,baseUrl:t}}export{V as _,D as a,F as c,U as d,z as f,d as g,r as h,O as i,P as l,I as m,E as n,x as o,W as p,k as r,S as s,H as t,a as u,n as v};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.