@jxsuite/studio 5.7.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/chunks/{cf-account-picker-882a7ecm.js → cf-account-picker-bb2yq946.js} +2 -2
  2. package/dist/chunks/content-source-t0q184js.js +4 -0
  3. package/dist/chunks/{convert-to-repeater-grfep2w8.js → convert-to-repeater-vqkt7s3s.js} +2 -2
  4. package/dist/chunks/entry-commands-fxzgcc4k.js +4 -0
  5. package/dist/chunks/{extension-sections-dp8endhx.js → extension-sections-8beq9ac3.js} +2 -2
  6. package/dist/chunks/file-ops-2n77759h.js +4 -0
  7. package/dist/chunks/files-fjy7zpxt.js +4 -0
  8. package/dist/chunks/{format-host-e2pjvd25.js → format-host-wj3mf3n8.js} +2 -2
  9. package/dist/chunks/fs-events-7kcgn4e9.js +4 -0
  10. package/dist/chunks/git-panel-7z2mpt2d.js +4 -0
  11. package/dist/chunks/{grid-view-5amhg604.js → grid-view-ca10def6.js} +2 -2
  12. package/dist/chunks/{iframe-host-t819mcg5.js → iframe-host-a0zjd6xp.js} +2 -2
  13. package/dist/chunks/{layers-4bsr82wz.js → layers-p677nrh5.js} +2 -2
  14. package/dist/chunks/layers-panel-y4w1dq90.js +4 -0
  15. package/dist/chunks/media-picker-xg7yjpz9.js +4 -0
  16. package/dist/chunks/menu-fpekzj6w.js +4 -0
  17. package/dist/chunks/publish-panel-xtbfgg2r.js +4 -0
  18. package/dist/chunks/quick-search-d3a6m7j3.js +4 -0
  19. package/dist/chunks/right-panel-31vbk5xp.js +4 -0
  20. package/dist/chunks/studio-1q6amtph.js +5 -0
  21. package/dist/chunks/{studio-56z7evx4.js → studio-3ck2a5c4.js} +2 -2
  22. package/dist/chunks/{studio-gh97gngt.js → studio-4fde4a0x.js} +2 -2
  23. package/dist/chunks/{studio-gfn1kpxj.js → studio-4jj9gme2.js} +3 -3
  24. package/dist/chunks/{studio-zpnk016a.js → studio-4m50vh74.js} +3 -3
  25. package/dist/chunks/{studio-dkn3x3hz.js → studio-4r0sjtx8.js} +2 -2
  26. package/dist/chunks/{studio-a7xqhc3n.js → studio-5d7wfmnp.js} +2 -2
  27. package/dist/chunks/{studio-ceb34dxj.js → studio-5gs9th4b.js} +2 -2
  28. package/dist/chunks/{studio-j6gnhvaa.js → studio-5vy2wfm5.js} +2 -2
  29. package/dist/chunks/{studio-spf2skgc.js → studio-7qvs7v0m.js} +2 -2
  30. package/dist/chunks/{studio-e6re3rk1.js → studio-84rtc120.js} +2 -2
  31. package/dist/chunks/{studio-nt06yybj.js → studio-8xcwewjq.js} +2 -2
  32. package/dist/chunks/{studio-cxt150pj.js → studio-aekhcdzw.js} +2 -2
  33. package/dist/chunks/{studio-222rqyyc.js → studio-bftp4n4b.js} +2 -2
  34. package/dist/chunks/{studio-xta2vxp6.js → studio-capk0583.js} +2 -2
  35. package/dist/chunks/{studio-wma2c6g8.js → studio-cbr9czkn.js} +2 -2
  36. package/dist/chunks/{studio-c9d3pxf7.js → studio-chdmwwzw.js} +2 -2
  37. package/dist/chunks/{studio-0k9mvpgj.js → studio-cp1gbff9.js} +2 -2
  38. package/dist/chunks/{studio-1x8x26k3.js → studio-cqmtbg2p.js} +2 -2
  39. package/dist/chunks/{studio-c6w3tq7t.js → studio-e47215hh.js} +2 -2
  40. package/dist/chunks/{studio-frb0qbf7.js → studio-fbx6twps.js} +2 -2
  41. package/dist/chunks/{studio-xk0z6msk.js → studio-fthwn4kf.js} +2 -2
  42. package/dist/chunks/{studio-0scebvb9.js → studio-g8dsj3d2.js} +2 -2
  43. package/dist/chunks/{studio-54g077x3.js → studio-ge5fqjth.js} +2 -2
  44. package/dist/chunks/{studio-p7c1agz0.js → studio-gjknvzam.js} +3 -3
  45. package/dist/chunks/{studio-mwxgyn9h.js → studio-hnvnfbdv.js} +3 -3
  46. package/dist/chunks/{studio-9mqfamps.js → studio-mk00zd5d.js} +2 -2
  47. package/dist/chunks/{studio-skzanb0k.js → studio-qa73881a.js} +2 -2
  48. package/dist/chunks/{studio-xry7tk3z.js → studio-rmn2dz59.js} +2 -2
  49. package/dist/chunks/{studio-eh0rac07.js → studio-rr4xkv81.js} +2 -2
  50. package/dist/chunks/{studio-f195h2hq.js → studio-tmeq6mjb.js} +2 -2
  51. package/dist/chunks/{studio-cvbkkfqb.js → studio-x5g1xk77.js} +2 -2
  52. package/dist/chunks/{studio-65fhspdd.js → studio-xg1942as.js} +2 -2
  53. package/dist/chunks/{studio-888knnkc.js → studio-xkfs0dp2.js} +2 -2
  54. package/dist/chunks/{studio-xy3tv3az.js → studio-zev8ssp1.js} +3 -3
  55. package/dist/chunks/{studio-tw7rre6s.js → studio-ztvcxm3w.js} +2 -2
  56. package/dist/chunks/{workspace-b69mgm0e.js → workspace-5vmgsagj.js} +2 -2
  57. package/dist/iframe-entry.js +3 -3
  58. package/dist/manifest.json +36 -36
  59. package/dist/studio.js +10 -10
  60. package/package.json +11 -11
  61. package/src/ui/schema-form.ts +6 -2
  62. package/dist/chunks/content-source-37x3vsap.js +0 -4
  63. package/dist/chunks/entry-commands-c5h3nqck.js +0 -4
  64. package/dist/chunks/file-ops-937cvqk6.js +0 -4
  65. package/dist/chunks/files-tznwe1p1.js +0 -4
  66. package/dist/chunks/fs-events-fv64ak3s.js +0 -4
  67. package/dist/chunks/git-panel-gb713ttc.js +0 -4
  68. package/dist/chunks/layers-panel-b6shnaax.js +0 -4
  69. package/dist/chunks/media-picker-ej0kdh1j.js +0 -4
  70. package/dist/chunks/menu-rtxf9chb.js +0 -4
  71. package/dist/chunks/publish-panel-bq36xcmj.js +0 -4
  72. package/dist/chunks/quick-search-zm00h9dh.js +0 -4
  73. package/dist/chunks/right-panel-pq2f71q3.js +0 -4
  74. package/dist/chunks/studio-693nhyky.js +0 -5
@@ -1,5 +1,5 @@
1
- import{p,We}from"./studio-y7jehjrp.js";import{te}from"./studio-ery42sqr.js";import{js,q1}from"./studio-yr04mv2j.js";import{ge,Xa,Q,v,re,k,tl,lh}from"./studio-fqq890ap.js";import{q,ym,kc,Ko,gv,bv,ma,_m,GC,m,u}from"./studio-cvbkkfqb.js";import{qt,wi,Lp,Zt,Dr,ck,Us,dk}from"./studio-1x8x26k3.js";import{hm}from"./studio-c6w3tq7t.js";import{kk,xI,_I,jd,jm}from"./studio-0k9mvpgj.js";import{Xo}from"./studio-spf2skgc.js";import{mc}from"./studio-9mqfamps.js";import{hs,pr}from"./studio-zpnk016a.js";import{la,Cb}from"./studio-xta2vxp6.js";import{vT,rC}from"./studio-ceb34dxj.js";import{wb}from"./studio-n78gjfy8.js";import{K}from"./studio-tp642n5g.js";var X={invokerTags:jm,popoverTags:jd},M="Popover",me={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function Z(e,r,o,n){let a=`${r}.${o}.${n.join("/")}`,l=e.get(a)??0;return e.set(a,l+1),l===0?a:`${a}#${l}`}function L(e,r){tl((l)=>l.source===M);let o=new Map,n=xI(e,X);for(let l of n){let g=l.fix===void 0?void 0:me[l.fix];k(l.severity,l.message,{detail:l.detail,key:Z(o,"popover",l.rule,l.path),source:M,tier:"problem",...g===void 0?{}:{action:g,actionArgs:{path:l.path}},...r===void 0?{}:{path:r}})}let a=vT(e,X);for(let l of a)k(l.severity,l.message,{detail:l.detail,key:Z(o,"dialog",l.rule,l.path),source:M,tier:"problem",...r===void 0?{}:{path:r}});return n.length+a.length}function z(e,r){let o=r?.path;if(!Array.isArray(o))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return o}function _(e){let r=u.value;if(!r)throw RangeError(`command "${e}" needs an open document`);return r}function ye(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=_("document.checkPopovers"),r=L(e.doc.document,e.documentPath??void 0);k.success(r===0?"No popover problems found in this document.":`${r} popover problem(s) filed.`,{key:"popover.run",source:M})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=lh(M),r=e.length;return{data:e,summary:r===0?"No popover problems found in this document.":`Filed ${r} popover problem${r===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,r)=>{let n=_("document.repairPopoverDisplay"),a=z("document.repairPopoverDisplay",r),l=K(n.doc.document,a),g=_I(l?.style);if(!g)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);q(n,(h)=>{for(let y of g.base)kc(h,a,y,"");for(let y of g.breakpoints)bv(h,a,[y],"display","");if(g.openDisplay!==null)gv(h,a,":popover-open","display",g.openDisplay)}),k.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:M})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,r)=>{let n=_("document.repairPopoverInvoker"),a=z("document.repairPopoverInvoker",r);q(n,(l)=>{Ko(l,a,"popovertarget"),Ko(l,a,"popovertargetaction")}),k.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:M})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,r)=>{let n=_("document.repairPopoverMode"),a=z("document.repairPopoverMode",r);q(n,(l)=>{Ko(l,a,"popover",kk)}),k.success(`Set \`popover\` to "${kk}".`,{key:"popover.repaired.mode",source:M})},title:"Set popover to auto",when:(e)=>e.document.open}]}function jE(e){e.registerAll(ye())}function bb(e,r){if(e===r)return!0;if(Array.isArray(e)&&Array.isArray(r))return e.length===r.length&&e.every((o,n)=>o===r[n]);if(e!==null&&r!==null&&typeof e==="object"&&typeof r==="object"&&!Array.isArray(e)&&!Array.isArray(r))return e.$ref===r.$ref;return!1}var F="grid://";function ds(e){switch(e.kind){case"pages":return`${F}pages`;case"library":return`${F}library`;case"collection":return`${F}collection/${encodeURIComponent(e.name)}`;default:return`${F}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function he(e){return e.startsWith(F)}function Kf(e){if(!he(e))return null;let r=e.slice(F.length).split("/");if(r[0]==="pages"&&r.length===1)return{kind:"pages"};if(r[0]==="library"&&r.length===1)return{kind:"library"};if(r[0]==="collection"&&r.length===2&&r[1])return{kind:"collection",name:decodeURIComponent(r[1])};if(r[0]==="data"&&r.length===3&&r[1]&&r[2])return{connection:decodeURIComponent(r[1]),kind:"data",table:decodeURIComponent(r[2])};return null}function jw(e){let r=Kf(e);if(!r)return null;switch(r.kind){case"pages":return"Pages · grid";case"library":return"Library";case"collection":return`${r.name} · grid`;default:return`${r.table} @ ${r.connection} · grid`}}var ee=0;function ne(e){let r=e.coalesceMs??800,o=e.now??(()=>Date.now()),n=v({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),a=null,l=(t,i,s)=>{let d=n.errors.get(t);if(d)d.set(i,s);else n.errors.set(t,new Map([[i,s]]))},g=(t,i)=>{let s=n.errors.get(t);if(s?.delete(i),s?.size===0)n.errors.delete(t)},h=(t)=>{if(n.redoStack.length=0,a){a.push(t);return}let i=n.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=r){i.after=t.after,i.at=t.at;return}n.undoStack.push(t)},y=(t,i,s)=>{let d=n.inserts.get(t);if(d){if(s===null)delete d[i];else d[i]=s;return}if(bb(s,e.resolveBaseline(t,i))){let c=n.pending.get(t);if(c?.delete(i),c?.size===0)n.pending.delete(t);return}let f=n.pending.get(t);if(f)f.set(i,{value:s});else n.pending.set(t,new Map([[i,{value:s}]]))},b=(t,i)=>{let s=n.inserts.get(t);if(s)return s[i]??null;let d=n.pending.get(t)?.get(i);return d?d.value:e.resolveBaseline(t,i)},S=(t,i)=>{let s=n.errors.get(t);return s?.get(i)??s?.get("*")??null},G=(t,i)=>{switch(t.kind){case"cell":{y(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")n.inserts.delete(t.tempKey);else n.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")n.inserts.set(t.tempKey,{...t.cells});else n.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")n.deletes.delete(t.rowKey);else n.deletes.add(t.rowKey);break}default:{let s=i==="undo"?t.ops.toReversed():t.ops;for(let d of s)G(d,i);break}}},T=()=>{if(a)throw Error("edit-buffer: groups may not nest");a=[]},C=()=>{let t=a;if(a=null,!t)return;if(t.length===1)n.undoStack.push(t[0]);else if(t.length>1)n.undoStack.push({kind:"group",ops:t})},R=(t)=>{let i=(s)=>{switch(s.kind){case"cell":return t(s.rowKey)?null:s;case"insert":case"drop-insert":return t(s.tempKey)?null:s;case"delete":return t(s.rowKey)?null:s;default:{let d=s.ops.map((f)=>i(f)).filter((f)=>f!==null);return d.length>0?{kind:"group",ops:d}:null}}};n.undoStack=n.undoStack.map(i).filter((s)=>s!==null),n.redoStack=n.redoStack.map(i).filter((s)=>s!==null)};return{applyCommitResult(t){let i=new Set;for(let s of t.cells)if(s.ok){let d=n.pending.get(s.rowKey);if(d?.delete(s.field),d?.size===0)n.pending.delete(s.rowKey);g(s.rowKey,s.field)}else if(l(s.rowKey,s.field,s.error??"Save failed"),s.stale)n.stale.add(s.rowKey);for(let s of t.inserts)if(s.ok)n.inserts.delete(s.tempKey),n.errors.delete(s.tempKey),i.add(s.tempKey);else l(s.tempKey,"*",s.error??"Insert failed");for(let s of t.deletes)if(s.ok)n.deletes.delete(s.rowKey),n.pending.delete(s.rowKey),n.errors.delete(s.rowKey),i.add(s.rowKey);else if(l(s.rowKey,"*",s.error??"Delete failed"),s.stale)n.stale.add(s.rowKey);for(let s of i)n.stale.delete(s);if(i.size>0)R((s)=>i.has(s))},buildBatch(){let t=[];for(let[i,s]of n.pending){if(n.deletes.has(i))continue;for(let[d,f]of s)t.push({baseline:e.resolveBaseline(i,d),field:d,rowKey:i,value:f.value})}return{cells:t,deletes:[...n.deletes].map((i)=>({rowKey:i})),inserts:[...n.inserts].map(([i,s])=>({cells:{...s},tempKey:i}))}},canRedo:()=>n.redoStack.length>0,canUndo:()=>n.undoStack.length>0,cellError:S,cellState(t,i){if(S(t,i)!==null)return"error";if(n.stale.has(t))return"stale";if(n.inserts.has(t)||n.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(n.deletes.has(t))return;let i=n.inserts.get(t);if(i){let s={...i};n.inserts.delete(t),n.errors.delete(t),n.stale.delete(t),h({cells:s,kind:"drop-insert",tempKey:t});return}n.deletes.add(t),h({kind:"delete",rowKey:t})},dirtyCount(){let t=n.inserts.size+n.deletes.size;for(let[i,s]of n.pending)if(!n.deletes.has(i))t+=s.size;return t},discardRow(t){n.pending.delete(t),n.deletes.delete(t),n.inserts.delete(t),n.errors.delete(t),n.stale.delete(t),R((i)=>i===t)},effectiveValue:b,beginGroup:T,endGroup:C,group(t){T();try{t()}finally{C()}},insertRow(t={}){ee+=1;let i=`__new-${ee}`;return n.inserts.set(i,{...t}),h({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>n.pending.size>0||n.inserts.size>0||n.deletes.size>0,isInsertKey:(t)=>n.inserts.has(t),markStale(t){for(let i of t)n.stale.add(i)},redo(){let t=n.redoStack.pop();if(!t)return!1;return G(t,"redo"),n.undoStack.push(t),!0},reset(){n.pending.clear(),n.inserts.clear(),n.deletes.clear(),n.errors.clear(),n.stale.clear(),n.undoStack.length=0,n.redoStack.length=0},rowState(t){if(n.deletes.has(t))return"pending-delete";if(n.inserts.has(t))return"pending-insert";if(n.stale.has(t))return"stale";if(n.pending.has(t)||n.errors.has(t))return"dirty";return"clean"},setCell(t,i,s){let d=b(t,i);if(bb(d,s))return;y(t,i,s),h({after:s,at:o(),before:d,field:i,kind:"cell",rowKey:t})},state:n,undo(){let t=n.undoStack.pop();if(!t)return!1;return G(t,"undo"),n.redoStack.push(t),!0}}}var oe={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function ie(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function we(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let r=e.type==="array"?void 0:e.format;if(ma(r))return"image";if(r==="date"||r==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function se(e){let r=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return r.charAt(0).toUpperCase()+r.slice(1)}function vb(e,r={}){let o=Object.entries(e?.properties??{}),n=new Set(e?.required),a=new Set(r.readonlyFields),l=o.map(([g,h])=>{let y=a.has(g)?"readonly":we(h),b=Array.isArray(h.enum)?Math.max(...h.enum.map((S)=>String(S).length),4):0;return{editable:y!=="readonly",field:g,kind:y,pk:g===r.idField,required:n.has(g),schema:h,title:se(g),widthHint:y==="enum"?ie(b+3):oe[y]}});return l.sort((g,h)=>{let y=(S)=>S.pk?0:S.required?1:2,b=y(g)-y(h);return b===0?0:b}),l}function yb(e,r=50){let o=e.slice(0,r),n=[];for(let a of o)for(let l of Object.keys(a))if(!n.includes(l))n.push(l);return n.map((a)=>{let l=o.map((y)=>y[a]).filter((y)=>y!==null&&y!==void 0&&y!==""),g=be(l),h=Math.max(...l.map((y)=>Io(y).length),a.length,4);return{editable:!0,field:a,kind:g,title:se(a),widthHint:g==="string"||g==="text"?ie(h):oe[g]}})}function be(e){if(e.length===0)return"string";if(e.some((o)=>Array.isArray(o)))return"array";let r=e.map(String);if(e.every((o)=>typeof o==="boolean")||r.every((o)=>/^(true|false)$/i.test(o)))return"boolean";if(e.every((o)=>typeof o==="number")||r.every((o)=>o.trim()!==""&&!Number.isNaN(Number(o.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(r.every((o)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(o)))return"date";if(r.some((o)=>o.length>200))return"text";return"string"}function Iu(e,r){if(e===null||e===void 0)return null;switch(r.kind){case"number":{if(typeof e==="number")return Number.isNaN(e)?null:e;let o=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(o==="")return null;let n=Number(o);return Number.isNaN(n)?null:n}case"boolean":{if(typeof e==="boolean")return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let o=String(e).trim();return o===""?[]:o.split(",").map((n)=>n.trim()).filter(Boolean)}case"reference":{if(typeof e==="object"&&e!==null&&"$ref"in e){let n=e.$ref;return typeof n==="string"&&n!==""?n:null}let o=String(e).trim();return o===""?null:o}default:{let o=String(e);return o===""?null:o}}}function Io(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(typeof e==="object")return e.$ref;return String(e)}var Hw="__key",U=new WeakMap;function Ha(e){return e?U.get(re(e))??null:null}function Ru(e,r){let o=v({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),n=new Map,a=(t)=>{n=new Map(t.map((i)=>[i.key,i]))},l=ne({resolveBaseline:(t,i)=>n.get(t)?.cells[i]??null}),g=async()=>{let t=await r.rows(o.query);o.rows=t.rows,o.total=t.total,a(t.rows)},h=(t)=>{let i=o.columns.filter((f)=>f.required&&f.editable);if(i.length===0)return null;let s=t.cells.filter((f)=>f.value===null&&i.some((c)=>c.field===f.field)).map((f)=>({error:"Required",field:f.field,ok:!1,rowKey:f.rowKey})),d=t.inserts.filter((f)=>i.some((c)=>f.cells[c.field]===null||f.cells[c.field]===void 0)).map((f)=>({error:`Missing required: ${i.filter((x)=>f.cells[x.field]===null||f.cells[x.field]===void 0).map((x)=>x.field).join(", ")}`,ok:!1,tempKey:f.tempKey}));if(s.length===0&&d.length===0)return null;return{cells:s,deletes:[],inserts:d}},y=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,b=(t,i,s)=>{if(s==="number")return(typeof t==="number"?t:0)-(typeof i==="number"?i:0);if(s==="boolean")return(t===!0?1:0)-(i===!0?1:0);return Io(t).localeCompare(Io(i))},S=()=>{let t=o.rows.map((d)=>d.key),{dir:i,orderBy:s}=o.query;if(s&&!r.capabilities.remoteSort){let d=o.columns.find((c)=>c.field===s)?.kind,f=i==="desc"?-1:1;t=t.toSorted((c,x)=>{let P=l.effectiveValue(c,s),j=l.effectiveValue(x,s);if(y(P)!==y(j))return y(P)?1:-1;return f*b(P,j,d)})}return o.grouping?[...G(t).values()].flat():t},G=(t)=>{let i=new Map;for(let s of t){let d=Io(l.effectiveValue(s,o.grouping)),f=i.get(d);if(f)f.push(s);else i.set(d,[s])}return i},T=null,C=()=>T?.refreshData(),R={addRow(t={}){let i=l.insertRow(t);return C(),i},bindView(t){T=t},buffer:l,deleteRows(t){if(t.length===0)return;l.group(()=>{for(let i of t)l.deleteRow(i)}),C()},discardRow(t){l.discardRow(t),C()},replaceAll(t,i){if(t==="")return 0;let s=o.columns.filter((c)=>c.editable&&(c.kind==="string"||c.kind==="text")),d=[...o.rows.map((c)=>c.key),...l.state.inserts.keys()],f=0;if(l.group(()=>{for(let c of d){if(l.rowState(c)==="pending-delete")continue;for(let x of s){let P=l.effectiveValue(c,x.field);if(typeof P==="string"&&P.includes(t))l.setCell(c,x.field,P.replaceAll(t,i)),f+=1}}}),f>0)C();return f},effectiveRows(){let t=(d)=>Array.isArray(d)?[...d]:d!==null&&typeof d==="object"?{$ref:d.$ref}:d,i=(d)=>{let f={[Hw]:d};for(let c of o.columns)f[c.field]=t(l.effectiveValue(d,c.field));return f},s=S().map((d)=>i(d));for(let[d]of l.state.inserts)s.push(i(d));return s},groups(){if(!o.grouping)return[];return[...G(S())].map(([t,i])=>({count:i.length,value:t}))},async load(){o.loading=!0,o.error=null;try{o.columns=await r.columns(),await g()}catch(t){o.error=te(t)}finally{o.loading=!1}C()},async refresh(){if(l.isDirty()){if(!await Xo("Refresh Grid",`Discard ${l.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}l.reset(),await r.refresh?.(),await this.load()},async save(){if(o.saving)return;let t=l.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){k.info("No grid changes to save.",{key:"grid.save"});return}let s=h(t);if(s){l.applyCommitResult(s),k.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await Xo("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let f=new Set(t.cells.map((c)=>c.rowKey)).size+t.inserts.length+t.deletes.length>5?la({title:"Saving grid"}):null;o.saving=!0;try{let c=await r.commit(t),x=(w,V)=>`${w}\x00${V}`,P=new Map(t.cells.map((w)=>[x(w.rowKey,w.field),w]));for(let w of c.cells){let V=P.get(x(w.rowKey,w.field));if(w.ok&&V){let Y=n.get(w.rowKey);if(Y)Y.cells[w.field]=V.value}}if(l.applyCommitResult(c),c.inserts.some((w)=>w.ok)||c.deletes.some((w)=>w.ok))await g();let I=c.cells.filter((w)=>w.ok).length+c.inserts.filter((w)=>w.ok).length+c.deletes.filter((w)=>w.ok).length,H=i-I,W=c.cells.filter((w)=>w.stale).length+c.deletes.filter((w)=>w.stale).length;if(H===0)k.success(`Saved ${I} change(s).`,{key:"grid.save"});else k.error(`Saved ${I} · ${H} failed${W?` (${W} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(c){k.error("Could not save the grid.",{action:"file.save",detail:te(c),key:"grid.save",source:"Data"})}finally{o.saving=!1,f?.done(),C()}},serializeForSource(){if(!r.serializeForSource)return null;return r.serializeForSource(l.buildBatch())},async setQuery(t){o.query=t,o.loading=!0;try{await g()}catch(i){o.error=te(i)}finally{o.loading=!1}C()},setGrouping(t){o.grouping=t,C()},async setSort(t){let i={...o.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!r.capabilities.remoteSort){o.query=i,C();return}await this.setQuery(i)},source:r,state:o,tab:e};return e.scope.run(()=>{Q(()=>{e.doc.dirty=l.isDirty()}),ym(e,{canRedo:()=>l.canRedo(),canUndo:()=>l.canUndo(),redo:()=>{l.redo(),C()},undo:()=>{l.undo(),C()}});let t=p();if(t.subscribeFileEvents&&r.backingPaths){let i=t.subscribeFileEvents((s)=>{let d=r.backingPaths(),f=new Set;for(let c of s){if(c.isDir)continue;let x=c.path.replaceAll("\\","/"),P=d.get(x);if(P!==void 0&&!mc(x))f.add(P)}if(f.size===0)return;if(l.isDirty()){let c=f.has("*")?o.rows.map((x)=>x.key):[...f];l.markStale(c),k.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),C()}else R.refresh()});Xa(i)}Xa(()=>{ym(e,null),U.delete(re(e)),r.dispose?.()})}),U.set(re(e),R),R}async function md(e){let o=Ha(e)?.serializeForSource();if(o)return o;await qt();let n=wi(e.doc.sourceFormat);if(n?.capabilities.serialize){let a=e.doc.content?.frontmatter||{},l=e.doc.document,g={...a,...l,children:l.children??[]};return Us(n.name,g,{mode:"roundtrip"})}if(e.doc.mode==="content"){let a=Dr();if(a){let l=e.doc.content?.frontmatter??{},g=Object.keys(l).length>0,h={...l,...e.doc.document};return Us(a.name,h,{frontmatter:g,mode:"roundtrip"})}}return pr(e.doc.document,e.doc.layout??null)}var ve=200,ke=500,Ce=2097152,D=new Map,B=!1,N=null,E=null,O=null,J=null;function xe(){let e=[];for(let r of m.tabs.values())if(r.doc.dirty&&r.documentPath)e.push(r);return e}async function le(){if(!We())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let r=new Set;for(let o of xe()){let n=o.documentPath.replace(/^\.\//,""),a;try{a=await md(o)}catch{continue}if(a.length>Ce)continue;if(r.add(n),D.get(n)===a)continue;D.set(n,a),await e.setPreviewOverlay(n,a)}for(let o of D.keys())if(!r.has(o))D.delete(o),await e.clearPreviewOverlay(o)}function ae(){if(!B)return;let e=Date.now();if(O??=e,E)clearTimeout(E);let r=e-O,o=Math.max(0,Math.min(ve,ke-r));E=setTimeout(()=>{E=null,O=null,J=le().finally(()=>{J=null})},o)}function HE(){ae()}function BE(){if(B)return;B=!0,N=ge(),N.run(()=>{Q(()=>{for(let e of m.tabs.values())e.doc.dirty,e.doc.document;ae()})})}function zE(){if(B=!1,E)clearTimeout(E),E=null;O=null,N?.stop(),N=null,D.clear()}async function Bw(){if(!B)return;if(E)clearTimeout(E),E=null,O=null;await J,await le()}var de=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,Se=new Set(["vnd","prs","x"]);function Pe(e){if(typeof e!=="string")return null;let[r,...o]=e.split(";"),n=(r??"").indexOf("/");if(n===-1)return null;let a=(r??"").slice(0,n).trim().toLowerCase(),l=(r??"").slice(n+1).trim().toLowerCase();if(!de.test(a)||!de.test(l))return null;let g=l.lastIndexOf("+"),h=g===-1?null:l.slice(g+1),y=g===-1?l:l.slice(0,g);if(h==="")return null;let b=y.indexOf("."),S=b===-1?null:y.slice(0,b),G=S!==null&&Se.has(S)?S:null,T=G===null?y:y.slice(G.length+1);if(T==="")return null;let C={};for(let R of o){let t=R.indexOf("=");if(t===-1)return null;let i=R.slice(0,t).trim().toLowerCase(),s=R.slice(t+1).trim();if(i==="")return null;if(s.startsWith('"')&&s.endsWith('"')&&s.length>=2)s=s.slice(1,-1);C[i]=s}return{parameters:C,subtype:T,suffix:h,tree:G,type:a}}function zw(e){let r=Pe(e);if(r===null)return null;let o=r.tree===null?"":`${r.tree}.`,n=r.suffix===null?"":`+${r.suffix}`;return`${r.type}/${o}${r.subtype}${n}`}var ce="text/markdown; variant=GFM",ue="application/yaml",ct={".markdown":`${ce}; charset=utf-8`,".md":`${ce}; charset=utf-8`,".yaml":`${ue}; charset=utf-8`,".yml":`${ue}; charset=utf-8`};async function Ge(e,r){let o=await ck(e.name,r);return dk(e,o)}async function Er(e,r){await qt();let o=Zt(e);if(!o||!o.capabilities.parse)throw Lp(e);return{...await Ge(o,r),format:o}}var D1=async(e,r)=>{if(e.documentPath&&Zt(e.documentPath)){let n=await Er(e.documentPath,r);return{document:n.document,frontmatter:n.frontmatter}}let o=hs(r);return e.doc.layout=o.layout,{document:o.document}};var fe=()=>{};function A1(e){fe=e}function A(e){let r=e.doc.document;fe(e.documentPath,r);let o=typeof r.tagName==="string"&&r.tagName.includes("-")?wb(r):null;if(o)k.warn(o,{key:`slots:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Components",tier:"problem"});L(r,e.documentPath??void 0)}function Re(e){return!hm(e.documentPath??"")}async function op(e=u.value){if(!e)return!1;if(await rC(e.id),_m(e))return k.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Collaboration"}),!1;if(!Re(e))return k.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,{key:`save.notADocument:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Save"}),!1;let r=Ha(e);if(r)return await r.save(),!e.doc.dirty;try{if(await GC(e))return A(e),!0;let o=await md(e);if(e.documentPath)return await p().writeFile(e.documentPath,o),e.doc.dirty=!1,Bw(),A(e),!0;if(e.fileHandle&&"createWritable"in e.fileHandle){let n=await e.fileHandle.createWritable();return await n.write(o),await n.close(),e.doc.dirty=!1,A(e),!0}k.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))k.error(`Could not save ${e.documentPath??e.id}.`,{action:"file.save",detail:te(o),key:`save:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Save"})}return!1}function Ee(e){return wi(e.doc.sourceFormat)??(e.doc.mode==="content"?Dr():void 0)}async function N1(){let e=u.value;if(!e)return;try{await qt();let r=Ee(e),o=await md(e),n=r?zw(r.mediaType)??"text/plain":"application/json",a=r?r.extensions[0]:".json",l=r?r.name:"Jx Component",g=r?`content${a}`:"component.json";if("showSaveFilePicker"in window){let h=e.documentPath?e.documentPath.split("/").pop():g,y=await window.showSaveFilePicker({suggestedName:h,types:[{accept:{[n]:[a]},description:l}]}),b=await y.createWritable();await b.write(o),await b.close(),e.doc.dirty=!1,A(e),k.success(`Exported as ${y.name}.`)}else{let h=new Blob([o],{type:n}),y=URL.createObjectURL(h),b=document.createElement("a");b.href=y,b.download=g,b.click(),URL.revokeObjectURL(y),e.doc.dirty=!1,A(e),k.success(`Downloaded ${g}.`)}}catch(r){if(!(r instanceof Error&&r.name==="AbortError"))k.error("Could not export the document.",{detail:te(r),source:"Export"})}}async function pe(e,r){let o=hm(e)?await Cb(e):await js({path:e});return q1(o,r)??""}async function Jf(e){let r=await pe(e.path,"delete"),o=`Delete ${e.name}? This cannot be undone.`;return Boolean(await Xo("Delete File",r===""?o:`${o} ${r}`,{confirmLabel:"Delete",destructive:!0}))}async function Yf(e,r="rename"){let o=await pe(e,r);return o===""?void 0:o}
1
+ import{p,We}from"./studio-y7jehjrp.js";import{te}from"./studio-ery42sqr.js";import{js,q1}from"./studio-yr04mv2j.js";import{ge,Xa,Q,v,re,k,tl,lh}from"./studio-fqq890ap.js";import{q,ym,kc,Ko,gv,bv,ma,_m,GC,m,u}from"./studio-x5g1xk77.js";import{qt,wi,Lp,Zt,Dr,ck,Us,dk}from"./studio-cqmtbg2p.js";import{hm}from"./studio-e47215hh.js";import{kk,xI,_I,jd,jm}from"./studio-cp1gbff9.js";import{Xo}from"./studio-7qvs7v0m.js";import{mc}from"./studio-mk00zd5d.js";import{hs,pr}from"./studio-4m50vh74.js";import{la,Cb}from"./studio-capk0583.js";import{vT,rC}from"./studio-5gs9th4b.js";import{wb}from"./studio-n78gjfy8.js";import{K}from"./studio-tp642n5g.js";var X={invokerTags:jm,popoverTags:jd},M="Popover",me={display:"document.repairPopoverDisplay","open-display":"document.repairPopoverDisplay",invoker:"document.repairPopoverInvoker",mode:"document.repairPopoverMode"};function Z(e,r,o,n){let a=`${r}.${o}.${n.join("/")}`,l=e.get(a)??0;return e.set(a,l+1),l===0?a:`${a}#${l}`}function L(e,r){tl((l)=>l.source===M);let o=new Map,n=xI(e,X);for(let l of n){let g=l.fix===void 0?void 0:me[l.fix];k(l.severity,l.message,{detail:l.detail,key:Z(o,"popover",l.rule,l.path),source:M,tier:"problem",...g===void 0?{}:{action:g,actionArgs:{path:l.path}},...r===void 0?{}:{path:r}})}let a=vT(e,X);for(let l of a)k(l.severity,l.message,{detail:l.detail,key:Z(o,"dialog",l.rule,l.path),source:M,tier:"problem",...r===void 0?{}:{path:r}});return n.length+a.length}function z(e,r){let o=r?.path;if(!Array.isArray(o))throw RangeError(`command "${e}" needs a "path" argument naming the popover`);return o}function _(e){let r=u.value;if(!r)throw RangeError(`command "${e}" needs an open document`);return r}function ye(){return[{category:"Document",group:"2_document",id:"document.checkPopovers",level:"document",menus:["palette"],requires:"an open document",run:()=>{let e=_("document.checkPopovers"),r=L(e.doc.document,e.documentPath??void 0);k.success(r===0?"No popover problems found in this document.":`${r} popover problem(s) filed.`,{key:"popover.run",source:M})},title:"Check Popovers",when:(e)=>e.document.open,aiTool:{description:"Check the open document for popover defects an author can fix — a base-rule `display` "+"that defeats the browser's own hiding of a closed popover, `popovertarget` on an "+"element that cannot invoke, a target naming no popover, a cut exit animation — and "+"file each as a Problem. The findings come back as data.",name:"check_popovers",report:()=>{let e=lh(M),r=e.length;return{data:e,summary:r===0?"No popover problems found in this document.":`Filed ${r} popover problem${r===1?"":"s"} in Problems.`}}}},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverDisplay",level:"document",menus:[],requires:"a popover whose base rule sets display",run:(e,r)=>{let n=_("document.repairPopoverDisplay"),a=z("document.repairPopoverDisplay",r),l=K(n.doc.document,a),g=_I(l?.style);if(!g)throw RangeError(`command "${"document.repairPopoverDisplay"}": nothing to move — this popover sets no display`);q(n,(h)=>{for(let y of g.base)kc(h,a,y,"");for(let y of g.breakpoints)bv(h,a,[y],"display","");if(g.openDisplay!==null)gv(h,a,":popover-open","display",g.openDisplay)}),k.success("Moved `display` into `:popover-open`.",{key:"popover.repaired.display",source:M})},title:"Move display into :popover-open",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverInvoker",level:"document",menus:[],requires:"an element carrying popovertarget that cannot invoke",run:(e,r)=>{let n=_("document.repairPopoverInvoker"),a=z("document.repairPopoverInvoker",r);q(n,(l)=>{Ko(l,a,"popovertarget"),Ko(l,a,"popovertargetaction")}),k.success("Removed the attributes, which did nothing on this element.",{key:"popover.repaired.invoker",source:M})},title:"Remove the inert popover attributes",when:(e)=>e.document.open},{args:{additionalProperties:!1,properties:{path:{items:{type:["string","number"]},type:"array"}},required:["path"],type:"object"},category:"Document",group:"2_document",id:"document.repairPopoverMode",level:"document",menus:[],requires:"a popover whose mode is not one of the three keywords",run:(e,r)=>{let n=_("document.repairPopoverMode"),a=z("document.repairPopoverMode",r);q(n,(l)=>{Ko(l,a,"popover",kk)}),k.success(`Set \`popover\` to "${kk}".`,{key:"popover.repaired.mode",source:M})},title:"Set popover to auto",when:(e)=>e.document.open}]}function jE(e){e.registerAll(ye())}function bb(e,r){if(e===r)return!0;if(Array.isArray(e)&&Array.isArray(r))return e.length===r.length&&e.every((o,n)=>o===r[n]);if(e!==null&&r!==null&&typeof e==="object"&&typeof r==="object"&&!Array.isArray(e)&&!Array.isArray(r))return e.$ref===r.$ref;return!1}var F="grid://";function ds(e){switch(e.kind){case"pages":return`${F}pages`;case"library":return`${F}library`;case"collection":return`${F}collection/${encodeURIComponent(e.name)}`;default:return`${F}data/${encodeURIComponent(e.connection)}/${encodeURIComponent(e.table)}`}}function he(e){return e.startsWith(F)}function Kf(e){if(!he(e))return null;let r=e.slice(F.length).split("/");if(r[0]==="pages"&&r.length===1)return{kind:"pages"};if(r[0]==="library"&&r.length===1)return{kind:"library"};if(r[0]==="collection"&&r.length===2&&r[1])return{kind:"collection",name:decodeURIComponent(r[1])};if(r[0]==="data"&&r.length===3&&r[1]&&r[2])return{connection:decodeURIComponent(r[1]),kind:"data",table:decodeURIComponent(r[2])};return null}function jw(e){let r=Kf(e);if(!r)return null;switch(r.kind){case"pages":return"Pages · grid";case"library":return"Library";case"collection":return`${r.name} · grid`;default:return`${r.table} @ ${r.connection} · grid`}}var ee=0;function ne(e){let r=e.coalesceMs??800,o=e.now??(()=>Date.now()),n=v({deletes:new Set,errors:new Map,inserts:new Map,pending:new Map,redoStack:[],stale:new Set,undoStack:[]}),a=null,l=(t,i,s)=>{let d=n.errors.get(t);if(d)d.set(i,s);else n.errors.set(t,new Map([[i,s]]))},g=(t,i)=>{let s=n.errors.get(t);if(s?.delete(i),s?.size===0)n.errors.delete(t)},h=(t)=>{if(n.redoStack.length=0,a){a.push(t);return}let i=n.undoStack.at(-1);if(t.kind==="cell"&&i?.kind==="cell"&&i.rowKey===t.rowKey&&i.field===t.field&&t.at-i.at<=r){i.after=t.after,i.at=t.at;return}n.undoStack.push(t)},y=(t,i,s)=>{let d=n.inserts.get(t);if(d){if(s===null)delete d[i];else d[i]=s;return}if(bb(s,e.resolveBaseline(t,i))){let c=n.pending.get(t);if(c?.delete(i),c?.size===0)n.pending.delete(t);return}let f=n.pending.get(t);if(f)f.set(i,{value:s});else n.pending.set(t,new Map([[i,{value:s}]]))},b=(t,i)=>{let s=n.inserts.get(t);if(s)return s[i]??null;let d=n.pending.get(t)?.get(i);return d?d.value:e.resolveBaseline(t,i)},S=(t,i)=>{let s=n.errors.get(t);return s?.get(i)??s?.get("*")??null},G=(t,i)=>{switch(t.kind){case"cell":{y(t.rowKey,t.field,i==="undo"?t.before:t.after);break}case"insert":{if(i==="undo")n.inserts.delete(t.tempKey);else n.inserts.set(t.tempKey,{...t.cells});break}case"drop-insert":{if(i==="undo")n.inserts.set(t.tempKey,{...t.cells});else n.inserts.delete(t.tempKey);break}case"delete":{if(i==="undo")n.deletes.delete(t.rowKey);else n.deletes.add(t.rowKey);break}default:{let s=i==="undo"?t.ops.toReversed():t.ops;for(let d of s)G(d,i);break}}},T=()=>{if(a)throw Error("edit-buffer: groups may not nest");a=[]},C=()=>{let t=a;if(a=null,!t)return;if(t.length===1)n.undoStack.push(t[0]);else if(t.length>1)n.undoStack.push({kind:"group",ops:t})},R=(t)=>{let i=(s)=>{switch(s.kind){case"cell":return t(s.rowKey)?null:s;case"insert":case"drop-insert":return t(s.tempKey)?null:s;case"delete":return t(s.rowKey)?null:s;default:{let d=s.ops.map((f)=>i(f)).filter((f)=>f!==null);return d.length>0?{kind:"group",ops:d}:null}}};n.undoStack=n.undoStack.map(i).filter((s)=>s!==null),n.redoStack=n.redoStack.map(i).filter((s)=>s!==null)};return{applyCommitResult(t){let i=new Set;for(let s of t.cells)if(s.ok){let d=n.pending.get(s.rowKey);if(d?.delete(s.field),d?.size===0)n.pending.delete(s.rowKey);g(s.rowKey,s.field)}else if(l(s.rowKey,s.field,s.error??"Save failed"),s.stale)n.stale.add(s.rowKey);for(let s of t.inserts)if(s.ok)n.inserts.delete(s.tempKey),n.errors.delete(s.tempKey),i.add(s.tempKey);else l(s.tempKey,"*",s.error??"Insert failed");for(let s of t.deletes)if(s.ok)n.deletes.delete(s.rowKey),n.pending.delete(s.rowKey),n.errors.delete(s.rowKey),i.add(s.rowKey);else if(l(s.rowKey,"*",s.error??"Delete failed"),s.stale)n.stale.add(s.rowKey);for(let s of i)n.stale.delete(s);if(i.size>0)R((s)=>i.has(s))},buildBatch(){let t=[];for(let[i,s]of n.pending){if(n.deletes.has(i))continue;for(let[d,f]of s)t.push({baseline:e.resolveBaseline(i,d),field:d,rowKey:i,value:f.value})}return{cells:t,deletes:[...n.deletes].map((i)=>({rowKey:i})),inserts:[...n.inserts].map(([i,s])=>({cells:{...s},tempKey:i}))}},canRedo:()=>n.redoStack.length>0,canUndo:()=>n.undoStack.length>0,cellError:S,cellState(t,i){if(S(t,i)!==null)return"error";if(n.stale.has(t))return"stale";if(n.inserts.has(t)||n.pending.get(t)?.has(i))return"dirty";return"clean"},deleteRow(t){if(n.deletes.has(t))return;let i=n.inserts.get(t);if(i){let s={...i};n.inserts.delete(t),n.errors.delete(t),n.stale.delete(t),h({cells:s,kind:"drop-insert",tempKey:t});return}n.deletes.add(t),h({kind:"delete",rowKey:t})},dirtyCount(){let t=n.inserts.size+n.deletes.size;for(let[i,s]of n.pending)if(!n.deletes.has(i))t+=s.size;return t},discardRow(t){n.pending.delete(t),n.deletes.delete(t),n.inserts.delete(t),n.errors.delete(t),n.stale.delete(t),R((i)=>i===t)},effectiveValue:b,beginGroup:T,endGroup:C,group(t){T();try{t()}finally{C()}},insertRow(t={}){ee+=1;let i=`__new-${ee}`;return n.inserts.set(i,{...t}),h({cells:{...t},kind:"insert",tempKey:i}),i},isDirty:()=>n.pending.size>0||n.inserts.size>0||n.deletes.size>0,isInsertKey:(t)=>n.inserts.has(t),markStale(t){for(let i of t)n.stale.add(i)},redo(){let t=n.redoStack.pop();if(!t)return!1;return G(t,"redo"),n.undoStack.push(t),!0},reset(){n.pending.clear(),n.inserts.clear(),n.deletes.clear(),n.errors.clear(),n.stale.clear(),n.undoStack.length=0,n.redoStack.length=0},rowState(t){if(n.deletes.has(t))return"pending-delete";if(n.inserts.has(t))return"pending-insert";if(n.stale.has(t))return"stale";if(n.pending.has(t)||n.errors.has(t))return"dirty";return"clean"},setCell(t,i,s){let d=b(t,i);if(bb(d,s))return;y(t,i,s),h({after:s,at:o(),before:d,field:i,kind:"cell",rowKey:t})},state:n,undo(){let t=n.undoStack.pop();if(!t)return!1;return G(t,"undo"),n.redoStack.push(t),!0}}}var oe={array:220,boolean:70,date:130,enum:140,image:180,number:110,readonly:200,reference:200,string:180,text:340};function ie(e){return Math.min(340,Math.max(90,Math.round(e*7.5)))}function we(e){if(e.$ref)return"reference";if(e.enum!==void 0&&Array.isArray(e.enum))return"enum";let r=e.type==="array"?void 0:e.format;if(ma(r))return"image";if(r==="date"||r==="date-time")return"date";switch(e.type){case"number":case"integer":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"readonly";default:return(e.maxLength??0)>200||e.format==="markdown"?"text":"string"}}function se(e){let r=e.replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[_-]+/g," ").trim();return r.charAt(0).toUpperCase()+r.slice(1)}function vb(e,r={}){let o=Object.entries(e?.properties??{}),n=new Set(e?.required),a=new Set(r.readonlyFields),l=o.map(([g,h])=>{let y=a.has(g)?"readonly":we(h),b=Array.isArray(h.enum)?Math.max(...h.enum.map((S)=>String(S).length),4):0;return{editable:y!=="readonly",field:g,kind:y,pk:g===r.idField,required:n.has(g),schema:h,title:se(g),widthHint:y==="enum"?ie(b+3):oe[y]}});return l.sort((g,h)=>{let y=(S)=>S.pk?0:S.required?1:2,b=y(g)-y(h);return b===0?0:b}),l}function yb(e,r=50){let o=e.slice(0,r),n=[];for(let a of o)for(let l of Object.keys(a))if(!n.includes(l))n.push(l);return n.map((a)=>{let l=o.map((y)=>y[a]).filter((y)=>y!==null&&y!==void 0&&y!==""),g=be(l),h=Math.max(...l.map((y)=>Io(y).length),a.length,4);return{editable:!0,field:a,kind:g,title:se(a),widthHint:g==="string"||g==="text"?ie(h):oe[g]}})}function be(e){if(e.length===0)return"string";if(e.some((o)=>Array.isArray(o)))return"array";let r=e.map(String);if(e.every((o)=>typeof o==="boolean")||r.every((o)=>/^(true|false)$/i.test(o)))return"boolean";if(e.every((o)=>typeof o==="number")||r.every((o)=>o.trim()!==""&&!Number.isNaN(Number(o.replaceAll(/[$€£¥,\s]/g,"")))))return"number";if(r.every((o)=>/^\d{4}-\d{2}-\d{2}([T ].*)?$/.test(o)))return"date";if(r.some((o)=>o.length>200))return"text";return"string"}function Iu(e,r){if(e===null||e===void 0)return null;switch(r.kind){case"number":{if(typeof e==="number")return Number.isNaN(e)?null:e;let o=String(e).trim().replaceAll(/[$€£¥,\s]/g,"");if(o==="")return null;let n=Number(o);return Number.isNaN(n)?null:n}case"boolean":{if(typeof e==="boolean")return e;return String(e).trim().toLowerCase()==="true"}case"array":{if(Array.isArray(e))return e.map(String);let o=String(e).trim();return o===""?[]:o.split(",").map((n)=>n.trim()).filter(Boolean)}case"reference":{if(typeof e==="object"&&e!==null&&"$ref"in e){let n=e.$ref;return typeof n==="string"&&n!==""?n:null}let o=String(e).trim();return o===""?null:o}default:{let o=String(e);return o===""?null:o}}}function Io(e){if(e===null||e===void 0)return"";if(Array.isArray(e))return e.join(", ");if(typeof e==="object")return e.$ref;return String(e)}var Hw="__key",U=new WeakMap;function Ha(e){return e?U.get(re(e))??null:null}function Ru(e,r){let o=v({columns:[],error:null,grouping:null,loading:!1,query:{},rows:[],saving:!1,total:0}),n=new Map,a=(t)=>{n=new Map(t.map((i)=>[i.key,i]))},l=ne({resolveBaseline:(t,i)=>n.get(t)?.cells[i]??null}),g=async()=>{let t=await r.rows(o.query);o.rows=t.rows,o.total=t.total,a(t.rows)},h=(t)=>{let i=o.columns.filter((f)=>f.required&&f.editable);if(i.length===0)return null;let s=t.cells.filter((f)=>f.value===null&&i.some((c)=>c.field===f.field)).map((f)=>({error:"Required",field:f.field,ok:!1,rowKey:f.rowKey})),d=t.inserts.filter((f)=>i.some((c)=>f.cells[c.field]===null||f.cells[c.field]===void 0)).map((f)=>({error:`Missing required: ${i.filter((x)=>f.cells[x.field]===null||f.cells[x.field]===void 0).map((x)=>x.field).join(", ")}`,ok:!1,tempKey:f.tempKey}));if(s.length===0&&d.length===0)return null;return{cells:s,deletes:[],inserts:d}},y=(t)=>t===null||t===""||Array.isArray(t)&&t.length===0,b=(t,i,s)=>{if(s==="number")return(typeof t==="number"?t:0)-(typeof i==="number"?i:0);if(s==="boolean")return(t===!0?1:0)-(i===!0?1:0);return Io(t).localeCompare(Io(i))},S=()=>{let t=o.rows.map((d)=>d.key),{dir:i,orderBy:s}=o.query;if(s&&!r.capabilities.remoteSort){let d=o.columns.find((c)=>c.field===s)?.kind,f=i==="desc"?-1:1;t=t.toSorted((c,x)=>{let P=l.effectiveValue(c,s),j=l.effectiveValue(x,s);if(y(P)!==y(j))return y(P)?1:-1;return f*b(P,j,d)})}return o.grouping?[...G(t).values()].flat():t},G=(t)=>{let i=new Map;for(let s of t){let d=Io(l.effectiveValue(s,o.grouping)),f=i.get(d);if(f)f.push(s);else i.set(d,[s])}return i},T=null,C=()=>T?.refreshData(),R={addRow(t={}){let i=l.insertRow(t);return C(),i},bindView(t){T=t},buffer:l,deleteRows(t){if(t.length===0)return;l.group(()=>{for(let i of t)l.deleteRow(i)}),C()},discardRow(t){l.discardRow(t),C()},replaceAll(t,i){if(t==="")return 0;let s=o.columns.filter((c)=>c.editable&&(c.kind==="string"||c.kind==="text")),d=[...o.rows.map((c)=>c.key),...l.state.inserts.keys()],f=0;if(l.group(()=>{for(let c of d){if(l.rowState(c)==="pending-delete")continue;for(let x of s){let P=l.effectiveValue(c,x.field);if(typeof P==="string"&&P.includes(t))l.setCell(c,x.field,P.replaceAll(t,i)),f+=1}}}),f>0)C();return f},effectiveRows(){let t=(d)=>Array.isArray(d)?[...d]:d!==null&&typeof d==="object"?{$ref:d.$ref}:d,i=(d)=>{let f={[Hw]:d};for(let c of o.columns)f[c.field]=t(l.effectiveValue(d,c.field));return f},s=S().map((d)=>i(d));for(let[d]of l.state.inserts)s.push(i(d));return s},groups(){if(!o.grouping)return[];return[...G(S())].map(([t,i])=>({count:i.length,value:t}))},async load(){o.loading=!0,o.error=null;try{o.columns=await r.columns(),await g()}catch(t){o.error=te(t)}finally{o.loading=!1}C()},async refresh(){if(l.isDirty()){if(!await Xo("Refresh Grid",`Discard ${l.dirtyCount()} pending change(s) and reload?`,{confirmLabel:"Discard & Reload",destructive:!0}))return}l.reset(),await r.refresh?.(),await this.load()},async save(){if(o.saving)return;let t=l.buildBatch(),i=t.cells.length+t.inserts.length+t.deletes.length;if(i===0){k.info("No grid changes to save.",{key:"grid.save"});return}let s=h(t);if(s){l.applyCommitResult(s),k.warn("Required cells are empty — fix the marked rows, then save again.",{key:"grid.save",source:"Data",tier:"problem"});return}if(t.deletes.length>0){if(!await Xo("Delete Rows",`Save will permanently delete ${t.deletes.length} row(s). Continue?`,{confirmLabel:"Delete & Save",destructive:!0}))return}let f=new Set(t.cells.map((c)=>c.rowKey)).size+t.inserts.length+t.deletes.length>5?la({title:"Saving grid"}):null;o.saving=!0;try{let c=await r.commit(t),x=(w,V)=>`${w}\x00${V}`,P=new Map(t.cells.map((w)=>[x(w.rowKey,w.field),w]));for(let w of c.cells){let V=P.get(x(w.rowKey,w.field));if(w.ok&&V){let Y=n.get(w.rowKey);if(Y)Y.cells[w.field]=V.value}}if(l.applyCommitResult(c),c.inserts.some((w)=>w.ok)||c.deletes.some((w)=>w.ok))await g();let I=c.cells.filter((w)=>w.ok).length+c.inserts.filter((w)=>w.ok).length+c.deletes.filter((w)=>w.ok).length,H=i-I,W=c.cells.filter((w)=>w.stale).length+c.deletes.filter((w)=>w.stale).length;if(H===0)k.success(`Saved ${I} change(s).`,{key:"grid.save"});else k.error(`Saved ${I} · ${H} failed${W?` (${W} stale)`:""} — kept pending.`,{action:"file.save",key:"grid.save",source:"Data"})}catch(c){k.error("Could not save the grid.",{action:"file.save",detail:te(c),key:"grid.save",source:"Data"})}finally{o.saving=!1,f?.done(),C()}},serializeForSource(){if(!r.serializeForSource)return null;return r.serializeForSource(l.buildBatch())},async setQuery(t){o.query=t,o.loading=!0;try{await g()}catch(i){o.error=te(i)}finally{o.loading=!1}C()},setGrouping(t){o.grouping=t,C()},async setSort(t){let i={...o.query};if(t)i.orderBy=t.field,i.dir=t.dir;else delete i.orderBy,delete i.dir;if(!r.capabilities.remoteSort){o.query=i,C();return}await this.setQuery(i)},source:r,state:o,tab:e};return e.scope.run(()=>{Q(()=>{e.doc.dirty=l.isDirty()}),ym(e,{canRedo:()=>l.canRedo(),canUndo:()=>l.canUndo(),redo:()=>{l.redo(),C()},undo:()=>{l.undo(),C()}});let t=p();if(t.subscribeFileEvents&&r.backingPaths){let i=t.subscribeFileEvents((s)=>{let d=r.backingPaths(),f=new Set;for(let c of s){if(c.isDir)continue;let x=c.path.replaceAll("\\","/"),P=d.get(x);if(P!==void 0&&!mc(x))f.add(P)}if(f.size===0)return;if(l.isDirty()){let c=f.has("*")?o.rows.map((x)=>x.key):[...f];l.markStale(c),k.warn("Grid rows changed on disk — marked stale; refresh to reload.",{key:"grid.stale",source:"Data"}),C()}else R.refresh()});Xa(i)}Xa(()=>{ym(e,null),U.delete(re(e)),r.dispose?.()})}),U.set(re(e),R),R}async function md(e){let o=Ha(e)?.serializeForSource();if(o)return o;await qt();let n=wi(e.doc.sourceFormat);if(n?.capabilities.serialize){let a=e.doc.content?.frontmatter||{},l=e.doc.document,g={...a,...l,children:l.children??[]};return Us(n.name,g,{mode:"roundtrip"})}if(e.doc.mode==="content"){let a=Dr();if(a){let l=e.doc.content?.frontmatter??{},g=Object.keys(l).length>0,h={...l,...e.doc.document};return Us(a.name,h,{frontmatter:g,mode:"roundtrip"})}}return pr(e.doc.document,e.doc.layout??null)}var ve=200,ke=500,Ce=2097152,D=new Map,B=!1,N=null,E=null,O=null,J=null;function xe(){let e=[];for(let r of m.tabs.values())if(r.doc.dirty&&r.documentPath)e.push(r);return e}async function le(){if(!We())return;let e=p();if(!e.setPreviewOverlay||!e.clearPreviewOverlay)return;let r=new Set;for(let o of xe()){let n=o.documentPath.replace(/^\.\//,""),a;try{a=await md(o)}catch{continue}if(a.length>Ce)continue;if(r.add(n),D.get(n)===a)continue;D.set(n,a),await e.setPreviewOverlay(n,a)}for(let o of D.keys())if(!r.has(o))D.delete(o),await e.clearPreviewOverlay(o)}function ae(){if(!B)return;let e=Date.now();if(O??=e,E)clearTimeout(E);let r=e-O,o=Math.max(0,Math.min(ve,ke-r));E=setTimeout(()=>{E=null,O=null,J=le().finally(()=>{J=null})},o)}function HE(){ae()}function BE(){if(B)return;B=!0,N=ge(),N.run(()=>{Q(()=>{for(let e of m.tabs.values())e.doc.dirty,e.doc.document;ae()})})}function zE(){if(B=!1,E)clearTimeout(E),E=null;O=null,N?.stop(),N=null,D.clear()}async function Bw(){if(!B)return;if(E)clearTimeout(E),E=null,O=null;await J,await le()}var de=/^[A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}$/,Se=new Set(["vnd","prs","x"]);function Pe(e){if(typeof e!=="string")return null;let[r,...o]=e.split(";"),n=(r??"").indexOf("/");if(n===-1)return null;let a=(r??"").slice(0,n).trim().toLowerCase(),l=(r??"").slice(n+1).trim().toLowerCase();if(!de.test(a)||!de.test(l))return null;let g=l.lastIndexOf("+"),h=g===-1?null:l.slice(g+1),y=g===-1?l:l.slice(0,g);if(h==="")return null;let b=y.indexOf("."),S=b===-1?null:y.slice(0,b),G=S!==null&&Se.has(S)?S:null,T=G===null?y:y.slice(G.length+1);if(T==="")return null;let C={};for(let R of o){let t=R.indexOf("=");if(t===-1)return null;let i=R.slice(0,t).trim().toLowerCase(),s=R.slice(t+1).trim();if(i==="")return null;if(s.startsWith('"')&&s.endsWith('"')&&s.length>=2)s=s.slice(1,-1);C[i]=s}return{parameters:C,subtype:T,suffix:h,tree:G,type:a}}function zw(e){let r=Pe(e);if(r===null)return null;let o=r.tree===null?"":`${r.tree}.`,n=r.suffix===null?"":`+${r.suffix}`;return`${r.type}/${o}${r.subtype}${n}`}var ce="text/markdown; variant=GFM",ue="application/yaml",ct={".markdown":`${ce}; charset=utf-8`,".md":`${ce}; charset=utf-8`,".yaml":`${ue}; charset=utf-8`,".yml":`${ue}; charset=utf-8`};async function Ge(e,r){let o=await ck(e.name,r);return dk(e,o)}async function Er(e,r){await qt();let o=Zt(e);if(!o||!o.capabilities.parse)throw Lp(e);return{...await Ge(o,r),format:o}}var D1=async(e,r)=>{if(e.documentPath&&Zt(e.documentPath)){let n=await Er(e.documentPath,r);return{document:n.document,frontmatter:n.frontmatter}}let o=hs(r);return e.doc.layout=o.layout,{document:o.document}};var fe=()=>{};function A1(e){fe=e}function A(e){let r=e.doc.document;fe(e.documentPath,r);let o=typeof r.tagName==="string"&&r.tagName.includes("-")?wb(r):null;if(o)k.warn(o,{key:`slots:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Components",tier:"problem"});L(r,e.documentPath??void 0)}function Re(e){return!hm(e.documentPath??"")}async function op(e=u.value){if(!e)return!1;if(await rC(e.id),_m(e))return k.warn(`You have read access to this session — changes to ${e.documentPath??"this document"} stay in your browser and cannot be saved.`,{action:"file.save",key:`save.readOnly:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Collaboration"}),!1;if(!Re(e))return k.warn(`${e.documentPath??"This file"} is a media file, so there is no document for Save to write.`,{key:`save.notADocument:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Save"}),!1;let r=Ha(e);if(r)return await r.save(),!e.doc.dirty;try{if(await GC(e))return A(e),!0;let o=await md(e);if(e.documentPath)return await p().writeFile(e.documentPath,o),e.doc.dirty=!1,Bw(),A(e),!0;if(e.fileHandle&&"createWritable"in e.fileHandle){let n=await e.fileHandle.createWritable();return await n.write(o),await n.close(),e.doc.dirty=!1,A(e),!0}k.warn("This document has no save target — use Export.",{key:"save.noTarget"})}catch(o){if(!(o instanceof Error&&o.name==="AbortError"))k.error(`Could not save ${e.documentPath??e.id}.`,{action:"file.save",detail:te(o),key:`save:${e.documentPath??e.id}`,...e.documentPath===null?{}:{path:e.documentPath},source:"Save"})}return!1}function Ee(e){return wi(e.doc.sourceFormat)??(e.doc.mode==="content"?Dr():void 0)}async function N1(){let e=u.value;if(!e)return;try{await qt();let r=Ee(e),o=await md(e),n=r?zw(r.mediaType)??"text/plain":"application/json",a=r?r.extensions[0]:".json",l=r?r.name:"Jx Component",g=r?`content${a}`:"component.json";if("showSaveFilePicker"in window){let h=e.documentPath?e.documentPath.split("/").pop():g,y=await window.showSaveFilePicker({suggestedName:h,types:[{accept:{[n]:[a]},description:l}]}),b=await y.createWritable();await b.write(o),await b.close(),e.doc.dirty=!1,A(e),k.success(`Exported as ${y.name}.`)}else{let h=new Blob([o],{type:n}),y=URL.createObjectURL(h),b=document.createElement("a");b.href=y,b.download=g,b.click(),URL.revokeObjectURL(y),e.doc.dirty=!1,A(e),k.success(`Downloaded ${g}.`)}}catch(r){if(!(r instanceof Error&&r.name==="AbortError"))k.error("Could not export the document.",{detail:te(r),source:"Export"})}}async function pe(e,r){let o=hm(e)?await Cb(e):await js({path:e});return q1(o,r)??""}async function Jf(e){let r=await pe(e.path,"delete"),o=`Delete ${e.name}? This cannot be undone.`;return Boolean(await Xo("Delete File",r===""?o:`${o} ${r}`,{confirmLabel:"Delete",destructive:!0}))}async function Yf(e,r="rename"){let o=await pe(e,r);return o===""?void 0:o}
2
2
  export{bb,ds,Kf,jw,vb,yb,Iu,Io,Hw,Ha,Ru,jE,md,HE,BE,zE,Bw,zw,Er,D1,A1,op,N1,Jf,Yf};
3
3
 
4
4
  //# debugId=1F31F44B7CF0874464756E2164756E21
5
- //# sourceMappingURL=studio-skzanb0k.js.map
5
+ //# sourceMappingURL=studio-qa73881a.js.map
@@ -1,7 +1,7 @@
1
- import{$o,bm,u}from"./studio-cvbkkfqb.js";import{y}from"./studio-zpnk016a.js";import{D}from"./studio-tp642n5g.js";var em=["application","project","document","selection"],fT=["global","canvas","caret","grid","code","dock","palette"],mT=["File","Edit","Selection","Insert","View","Document","Project","Source Control","Publish","Assistant","Collaborate","Help"],d=["commandbar/primary","commandbar/overflow","statusbar/project","statusbar/document","statusbar/selection","context/element","context/file","context/layer","context/tab","context/pane","blockbar","blockbar/format","outline/row","settings/menu","palette","never"],m={"commandbar/primary":{admits:["application","document"],note:"document only for Save / Undo / Redo / Open in Browser, by frequency; ≤5 total"},"commandbar/overflow":{admits:["application","project","document"],note:"never selection — the Command Bar is not a selection surface"},"statusbar/project":{admits:["project"],note:"the status bar's left field"},"statusbar/document":{admits:["document"],note:"the status bar's centre field"},"statusbar/selection":{admits:["selection"],note:"the status bar's right field"},"context/element":{admits:["selection"],note:"the canvas element menu acts on a selection"},"context/file":{admits:["project"],note:"a file row addresses the project's file set"},"context/layer":{admits:["selection"],note:"an outline row IS a selection"},"context/tab":{admits:["document"],note:"a tab addresses one document"},"context/pane":{admits:["document"],note:"a pane hosts one document"},blockbar:{admits:["selection"],note:"the floating bar owns selection-scoped verbs"},"blockbar/format":{admits:["selection"],note:"the bar's inline-format cluster — a range inside the selection is still the selection"},"outline/row":{admits:["selection"],note:"row actions act on the row's node"},"settings/menu":{admits:["application","project"],note:"the rail foot's gear menu — the settings family. It is a MENU, not a pinned slot, so it "+"may host two levels for the reason commandbar/overflow does: a menu prints each row's own name, chord and gate, and draws a divider where the level changes. The rail's PINNED groups stay single-level, in PANEL_PLACEMENT_MATRIX"},palette:{admits:["application","project","document","selection"],note:"the level-agnostic surface; it groups rows by level"},never:{admits:["application","project","document","selection"],note:"keyboard- and API-only; no rendered surface to be misplaced in"}},p=["rail/project","rail/document","navigator","inspector","dock.bottom"],f={"rail/project":{admits:["project"],note:"the rail's upper group — Files, Search, Source Control, Problems"},"rail/document":{admits:["document"],note:"the rail's lower group — Outline, Page, Data, Packages"},navigator:{admits:["project","document"],note:"whichever level the hosted panel declares; the panel header prints it"},inspector:{admits:["selection"],note:"the Inspector's tabs are selection surfaces"},"dock.bottom":{admits:["project","document"],note:"the panel header states which"}};function g(e){return e==="bottom"?"dock.bottom":e}function P(e){let t=[g(e.dock)];if(e.rail!==!1)t.push(`rail/${e.level}`);return t}function v(e){return p.includes(e)}function r(e){let t=[];if(!i(e.level))return t.push({panelId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${em.join(", ")})`}),t;for(let n of P(e)){if(!v(n)){t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" and would render in "${n}", which is not a panel `+"placement — the rail has a group for project and one for document, and nothing else"});continue}let o=f[n];if(!o.admits.includes(e.level))t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function b(e){return d.includes(e)}function i(e){return em.includes(e)}function gT(e){let t=[];if(!i(e.level))return t.push({commandId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${em.join(", ")})`}),t;for(let n of e.menus??[]){if(!b(n)){t.push({commandId:e.id,placement:String(n),level:e.level,message:`declares unknown placement "${String(n)}"`});continue}let o=m[n];if(!o.admits.includes(e.level))t.push({commandId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function vd(){let e=bm();return e.project.open=D!==null,e.project.isMultilingual=($o(D?.projectConfig??{}).i18n?.locales.length??0)>1,e.git.dirtyCount=y.git.status?.files?.length??0,e.document.open=u.value!==null,e}var h=/^[a-z][\w-]*$/,a=new Map;function qn(e){if(!h.test(e.id))throw Error(`Panel id "${e.id}" is malformed — expected /^[a-z][\\w-]*$/, because the id is also `+`the region "navigator/panel:${e.id}" and the value view.setActivity accepts.`);if(a.has(e.id))throw Error(`Panel "${e.id}" is already registered — a second definition site is the defect this `+"registry exists to prevent.");let t=r({id:e.id,level:e.level,dock:e.dock,rail:e.rail});if(t.length>0){let n=t.map((o)=>` ✗ ${e.id} ${o.message}`).join(`
1
+ import{$o,bm,u}from"./studio-x5g1xk77.js";import{y}from"./studio-4m50vh74.js";import{D}from"./studio-tp642n5g.js";var em=["application","project","document","selection"],fT=["global","canvas","caret","grid","code","dock","palette"],mT=["File","Edit","Selection","Insert","View","Document","Project","Source Control","Publish","Assistant","Collaborate","Help"],d=["commandbar/primary","commandbar/overflow","statusbar/project","statusbar/document","statusbar/selection","context/element","context/file","context/layer","context/tab","context/pane","blockbar","blockbar/format","outline/row","settings/menu","palette","never"],m={"commandbar/primary":{admits:["application","document"],note:"document only for Save / Undo / Redo / Open in Browser, by frequency; ≤5 total"},"commandbar/overflow":{admits:["application","project","document"],note:"never selection — the Command Bar is not a selection surface"},"statusbar/project":{admits:["project"],note:"the status bar's left field"},"statusbar/document":{admits:["document"],note:"the status bar's centre field"},"statusbar/selection":{admits:["selection"],note:"the status bar's right field"},"context/element":{admits:["selection"],note:"the canvas element menu acts on a selection"},"context/file":{admits:["project"],note:"a file row addresses the project's file set"},"context/layer":{admits:["selection"],note:"an outline row IS a selection"},"context/tab":{admits:["document"],note:"a tab addresses one document"},"context/pane":{admits:["document"],note:"a pane hosts one document"},blockbar:{admits:["selection"],note:"the floating bar owns selection-scoped verbs"},"blockbar/format":{admits:["selection"],note:"the bar's inline-format cluster — a range inside the selection is still the selection"},"outline/row":{admits:["selection"],note:"row actions act on the row's node"},"settings/menu":{admits:["application","project"],note:"the rail foot's gear menu — the settings family. It is a MENU, not a pinned slot, so it "+"may host two levels for the reason commandbar/overflow does: a menu prints each row's own name, chord and gate, and draws a divider where the level changes. The rail's PINNED groups stay single-level, in PANEL_PLACEMENT_MATRIX"},palette:{admits:["application","project","document","selection"],note:"the level-agnostic surface; it groups rows by level"},never:{admits:["application","project","document","selection"],note:"keyboard- and API-only; no rendered surface to be misplaced in"}},p=["rail/project","rail/document","navigator","inspector","dock.bottom"],f={"rail/project":{admits:["project"],note:"the rail's upper group — Files, Search, Source Control, Problems"},"rail/document":{admits:["document"],note:"the rail's lower group — Outline, Page, Data, Packages"},navigator:{admits:["project","document"],note:"whichever level the hosted panel declares; the panel header prints it"},inspector:{admits:["selection"],note:"the Inspector's tabs are selection surfaces"},"dock.bottom":{admits:["project","document"],note:"the panel header states which"}};function g(e){return e==="bottom"?"dock.bottom":e}function P(e){let t=[g(e.dock)];if(e.rail!==!1)t.push(`rail/${e.level}`);return t}function v(e){return p.includes(e)}function r(e){let t=[];if(!i(e.level))return t.push({panelId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${em.join(", ")})`}),t;for(let n of P(e)){if(!v(n)){t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" and would render in "${n}", which is not a panel `+"placement — the rail has a group for project and one for document, and nothing else"});continue}let o=f[n];if(!o.admits.includes(e.level))t.push({panelId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function b(e){return d.includes(e)}function i(e){return em.includes(e)}function gT(e){let t=[];if(!i(e.level))return t.push({commandId:e.id,placement:"—",level:String(e.level),message:`declares unknown level "${String(e.level)}" (expected one of: ${em.join(", ")})`}),t;for(let n of e.menus??[]){if(!b(n)){t.push({commandId:e.id,placement:String(n),level:e.level,message:`declares unknown placement "${String(n)}"`});continue}let o=m[n];if(!o.admits.includes(e.level))t.push({commandId:e.id,placement:n,level:e.level,message:`is level "${e.level}" but "${n}" admits only ${o.admits.join(", ")} — ${o.note}`})}return t}function vd(){let e=bm();return e.project.open=D!==null,e.project.isMultilingual=($o(D?.projectConfig??{}).i18n?.locales.length??0)>1,e.git.dirtyCount=y.git.status?.files?.length??0,e.document.open=u.value!==null,e}var h=/^[a-z][\w-]*$/,a=new Map;function qn(e){if(!h.test(e.id))throw Error(`Panel id "${e.id}" is malformed — expected /^[a-z][\\w-]*$/, because the id is also `+`the region "navigator/panel:${e.id}" and the value view.setActivity accepts.`);if(a.has(e.id))throw Error(`Panel "${e.id}" is already registered — a second definition site is the defect this `+"registry exists to prevent.");let t=r({id:e.id,level:e.level,dock:e.dock,rail:e.rail});if(t.length>0){let n=t.map((o)=>` ✗ ${e.id} ${o.message}`).join(`
2
2
  `);throw Error(`Panel "${e.id}" violates the level × placement matrix:
3
3
  ${n}`)}if(e.railLabel!==void 0&&(e.railLabel.trim()===""||!e.title.startsWith(e.railLabel)))throw Error(`Panel "${e.id}" declares railLabel "${e.railLabel}", which is not a leading part of its title "${e.title}": the rail button's accessible name is the title, and the words on screen must be inside it (WCAG 2.5.3, Label in Name).`);a.set(e.id,e)}function Au(e){return a.get(e)}function Lb(e){let t=[...a.values()];return e?t.filter((n)=>n.dock===e):t}function Ib(e,t){return e.when?e.when(t):!0}var s=[{level:"project",label:"Project"},{level:"document",label:"Document"}];function c(){return Lb().filter((e)=>e.rail!==!1)}function V1(e){let t=c();return s.map(({level:n,label:o})=>({level:n,label:o,panels:t.filter((l)=>l.level===n&&Ib(l,e))})).filter((n)=>n.panels.length>0)}function bT(){let e=c();return s.flatMap(({level:t})=>e.filter((n)=>n.level===t))}
4
4
  export{em,fT,mT,gT,vd,qn,Au,Lb,Ib,V1,bT};
5
5
 
6
6
  //# debugId=54344699E4A405A564756E2164756E21
7
- //# sourceMappingURL=studio-xry7tk3z.js.map
7
+ //# sourceMappingURL=studio-rmn2dz59.js.map
@@ -1,5 +1,5 @@
1
- import{p}from"./studio-y7jehjrp.js";import{qt,Vs,Ka}from"./studio-1x8x26k3.js";import{ne}from"./studio-0k9mvpgj.js";import{T,R,on,Rc,vs}from"./studio-spf2skgc.js";import{v}from"./studio-fqq890ap.js";import{u}from"./studio-cvbkkfqb.js";import{Xg,lE,Ff,Lo}from"./studio-mwxgyn9h.js";import{Nd,Zo,D}from"./studio-tp642n5g.js";var N={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPalette",$description:'The command palette: a `role="combobox"` field over the kit\'s `jx-listbox`, whose rows are `jx-option`s the host projects. `rows` is the ranked set for the current mode and query; `activeId` is the highlight, and it is ONE string — the id the field points `aria-activedescendant` at and the id the listbox is handed as `active`, so a key moves the caret without the rows reconciling and no row re-decides its own flag. The FIELD is not a `jx-combobox`: this one carries a mode chip inside its box, its Enter runs a command rather than committing a value, and its panel is a centred scrim rather than a popover under a control. Every gesture calls back into panels/quick-search.ts, which owns the modes, the ranking, the recents and what a row does.',tagName:"div",attributes:{part:"palette"},style:{display:"contents",'& [part="overlay"]':{position:"fixed",inset:"0",zIndex:"1000",display:"flex",justifyContent:"center",paddingTop:"60px",background:"rgba(0, 0, 0, 0.4)"},'& [part="overlay"][hidden]':{display:"none"},'& [part="panel"]':{width:"560px",maxWidth:"calc(100vw - 32px)",maxHeight:"420px",display:"flex",flexDirection:"column",alignSelf:"flex-start",background:"var(--jx-bg-overlay)",border:"1px solid var(--jx-border)",borderRadius:"var(--jx-radius-md)",boxShadow:"var(--jx-shadow-dialog)",color:"var(--jx-fg)",fontFamily:"var(--jx-font-sans)",overflow:"hidden"},'& [part="input-row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",paddingLeft:"var(--jx-space-4)",background:"var(--jx-bg-input)",borderBottom:"1px solid var(--jx-border)"},'& [part="chip-slot"], & [part="empty-slot"], & [part="section-slot"], & [part="trailing-slot"]':{display:"contents"},'& [part="chip"]':{display:"inline-flex",alignItems:"center",gap:"var(--jx-space-1)",flexShrink:"0",padding:"2px var(--jx-space-1) 2px var(--jx-space-3)",borderRadius:"var(--jx-radius-sm)",background:"var(--jx-accent-solid)",color:"var(--jx-accent-fg)",fontSize:"var(--jx-text-sm)"},'& [part="chip-remove"] > [part="control"]':{color:"inherit",opacity:"0.8",":hover":{opacity:"1",background:"transparent"}},'& [part="input"]':{flex:"1",minWidth:"0",padding:"var(--jx-space-4) var(--jx-space-5) var(--jx-space-4) var(--jx-space-1)",font:"inherit",fontSize:"var(--jx-text-lg)",border:"none",outline:"none",background:"none",color:"var(--jx-fg)","::placeholder":{color:"var(--jx-fg-muted)"},":focus-visible":{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"}},'& [part="results"]':{$description:"The list is the kit's: a `jx-listbox` of `jx-option`, so the highlight is ONE id — `active`, the same string the field points `aria-activedescendant` at — and the listbox's sidecar is the single writer of every row's `selected`. What this surface still decides is density. The kit's row pads itself by `--jx-space-3`; the other half of the 16px optical margin the panel has always had sits here, on the list, so the heading, the rows and the empty sentence line up on one edge instead of each naming it.",flex:"1",paddingInline:"var(--jx-space-3)"},'& [part="option"] [part="label"]':{fontWeight:"500"},'& [part="option"] [part="description"]':{$description:"A `jx-select` row's note is a category at the END of the row, so the kit pushes it there with an auto margin. A palette row's note is a CONTINUATION of its name — the file's directory, the command's category — and the far edge belongs to the chord, which is how this surface teaches the keyboard it replaced. So the auto margin moves to the end slot.",marginInlineStart:"0"},'& [part="option"] [part="end"]':{marginInlineStart:"auto"},'& [part="option"][aria-disabled="true"]':{$description:"An unavailable command is greyed with its `requires` sentence as the subtitle, and that sentence is the reason the row is on screen at all. The kit fades the whole row to 0.45, which would take a muted grey below any readable contrast — so the row keeps its ink and only the name and the glyph dim.",opacity:"1"},'& [part="option"][aria-disabled="true"] [part="label"], & [part="option"][aria-disabled="true"] [part="icon"]':{opacity:"0.45"},'& [part="chord"]':{flexShrink:"0",fontFamily:"inherit",fontSize:"var(--jx-text-xs)",color:"var(--jx-fg-muted)",border:"1px solid var(--jx-border)",borderRadius:"var(--jx-radius-sm)",padding:"0 5px"},'& [part="option"][aria-selected="true"] [part="chord"]':{color:"inherit",borderColor:"currentColor"},'& [part="badge"]':{fontSize:"var(--jx-text-xs)",padding:"1px var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",background:"var(--jx-border)",color:"var(--jx-fg-dim)"},'& [part="hint"]':{padding:"var(--jx-space-2) var(--jx-space-5)",borderTop:"1px solid var(--jx-border)",color:"var(--jx-fg-muted)",fontSize:"var(--jx-text-xs)"},'& [part="hint"] kbd':{fontFamily:"inherit",color:"var(--jx-fg-dim)"}},children:[{tagName:"div",attributes:{part:"overlay",hidden:"${state.open ? null : ''}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/close"},value:[]}]},children:[{tagName:"div",attributes:{part:"panel"},onclick:{$prototype:"Function",body:[{stopPropagation:!0}]},children:[{tagName:"div",attributes:{part:"input-row"},children:[{tagName:"span",attributes:{part:"chip-slot",role:"none"},$switch:{$ref:"#/state/hasChip"},cases:{true:{tagName:"span",attributes:{part:"chip"},children:[{tagName:"span",attributes:{part:"chip-label"},textContent:"${state.chipLabel}"},{tagName:"jx-action-button",$props:{label:"Clear mode",hint:"Clear mode (Backspace)",icon:"x",size:"sm"},attributes:{part:"chip-remove"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/clearMode"},value:[]}]}}]}}},{tagName:"input",attributes:{part:"input",type:"text",role:"combobox","aria-controls":"quick-search-listbox","aria-expanded":"${state.expanded ? 'true' : 'false'}","aria-activedescendant":"${state.activeId || null}","aria-autocomplete":"list","aria-label":"${state.placeholder}",placeholder:"${state.placeholder}"},value:{$ref:"#/state/query"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/input"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{ArrowDown:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/move"},value:[1]}],ArrowUp:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/move"},value:[-1]}],Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/activate"},value:[]}],Escape:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/close"},value:[]}],Backspace:[{$switch:{$ref:"#/state/canClearMode"},cases:{true:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/clearMode"},value:[]}]}}]}}]}}]},{tagName:"jx-listbox",attributes:{part:"results",id:"quick-search-listbox"},$props:{label:"Results",active:"${state.activeId}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activateRow"},value:[{$ref:"event#/detail"}]}],description:"One handler for every row, because a row's `select` bubbles. The detail is the row's `value`, which is the index it occupies in `rows` — the same number a hover names, and the number the id is built from."},children:[{tagName:"div",attributes:{part:"empty-slot",role:"none"},$switch:{$ref:"#/state/isEmpty"},cases:{true:{tagName:"div",attributes:{part:"empty"},textContent:"${state.emptyHint}"}}},{tagName:"div",attributes:{part:"section-slot",role:"none"},$switch:{$ref:"#/state/showSection"},cases:{true:{tagName:"div",attributes:{part:"group-heading"},textContent:"${state.sectionLabel}"}}},{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"jx-option",attributes:{part:"option",id:"quick-search-option-${$map.index}","data-kind":"${$map.item.kind}"},$props:{value:"${$map.index}",label:{$ref:"$map/item/name"},description:{$ref:"$map/item/detail"},disabled:{$ref:"$map/item/disabled"}},onmouseenter:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/hover"},value:[{$ref:"$map/index"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"span",attributes:{slot:"end",part:"trailing-slot"},$switch:{$ref:"$map/item/trailing"},cases:{chord:{tagName:"kbd",attributes:{part:"chord"},textContent:"${$map.item.chord}"},recent:{tagName:"span",attributes:{part:"badge"},textContent:"recent"}}}]}}]},{tagName:"div",attributes:{part:"hint"},children:[{tagName:"kbd",textContent:"↑↓"}," move · ",{tagName:"kbd",textContent:"↵"}," run · ",{tagName:"kbd",textContent:"?"}," modes · ",{tagName:"kbd",textContent:">"}," commands · ",{tagName:"kbd",textContent:"@"}," elements"]}]}]}]};var P=[{mode:"files",prefix:"",chip:"Files",placeholder:"Go to a file…",description:"Open a file by any part of its path — pgblog finds pages/blog/index.md."},{mode:"commands",prefix:">",chip:"Commands",placeholder:"Run a command…",description:"Run anything Studio can do, with its keyboard shortcut printed beside it."},{mode:"nodes",prefix:"@",chip:"Symbols",placeholder:"Go to an element in this document…",description:"Select an element in the open document by its Outline name."},{mode:"projects",prefix:"",chip:"Recent Projects",placeholder:"Open a recent project…",description:"Reopen a project you have had open before."},{mode:"picker",prefix:"?",chip:"Modes",placeholder:"Type ? for modes, > for commands, @ for elements…",description:"List these modes."}],X=new Map(P.map((e)=>[e.mode,e])),E=P.filter((e)=>e.prefix!=="");function F(e){return X.get(e)??P[0]}function O(e,t,n){let r=E.find((i)=>t.startsWith(i.prefix));if(r)return O(r.mode,t.slice(1),n);let a=e;if(a==="picker"&&t.trim()!=="")a="files";if(a==="files"&&!n)a="projects";return{mode:a,query:t}}var Y=new Set(["/","-","_","."," "]);function V(e,t){if(t==="")return 0;let n=e.toLowerCase(),r=t.toLowerCase(),a=n.lastIndexOf("/")+1,i=0,o=0,x=-2;for(let G of r){let m=n.indexOf(G,o);if(m===-1)return null;if(m===x+1)i+=8;if(m===0||Y.has(n[m-1]??""))i+=6;if(m>=a)i+=4;x=m,o=m+1}return i-x*0.01-n.length*0.001}function k(e,t,n){let r=[];for(let[a,i]of e.entries()){let o=V(n(i),t);if(o!==null)r.push({index:a,item:i,score:o})}return r.toSorted((a,i)=>i.score-a.score||a.index-i.index).map((a)=>a.item)}function q(e){let t=e.args,n=t?.properties;if(!t||!n)return{kind:"none"};let r=Object.keys(n);if(r.length!==1)return{kind:"unsupported"};let a=r[0],i=n[a];if(i.enum)return{kind:"choice",name:a,choices:i.enum.map((o)=>({label:String(o),value:o}))};if(i.type==="boolean")return{kind:"choice",name:a,choices:[{label:"on",value:!0},{label:"off",value:!1}]};return{kind:"unsupported"}}function S(e){return`quick-search-option-${e}`}var _="jx-studio-recent-commands",Z=6;function L(){try{let e=JSON.parse(localStorage.getItem(_)||"[]");return Array.isArray(e)?e.filter((t)=>typeof t==="string"):[]}catch{return[]}}function ee(e){let t=[e,...L().filter((n)=>n!==e)].slice(0,Z);try{localStorage.setItem(_,JSON.stringify(t))}catch{}}var z=null,f=!1,g="picker",d="",c=0,b=null,w=!1,s=null;function H(){return vs("popover","quick-search")}function P_(e){z=e??null}function $f(e="files"){f=!0,g=e,d="",c=0,s=null,b=null,l(),ve(),C()}function y(){f=!1,s=null,l()}function J(){return D?D.projectRoot??null:null}function B(){return D!=null}function Q(){return O(g,d,B())}function W(e){let t=e.split("/");return t.pop(),t.length>0?t.join("/"):""}function te(e){if(e.startsWith("/home/"))return`~/${e.split("/").slice(3).join("/")}`;return e}async function C(){if(!f||b!==null||w||!B())return;w=!0,l();try{await qt(),b=(await p().searchFiles("",Ka())).map((t)=>({kind:"file",path:t.path,name:t.name??t.path.split("/").pop()??"",detail:W(t.path),recent:!1}))}catch{b=[]}w=!1,l()}function oe(e){if(e.trim()==="")return lE(J()??void 0).map((t)=>({kind:"file",path:t.path,name:t.name,detail:W(t.path),recent:!0}));return k(b??[],e.trim(),(t)=>t.path)}function re(e){let t=Xg().map((n)=>({kind:"project",root:n.root,name:n.name,detail:te(n.root)}));return k(t,e.trim(),(n)=>`${n.name}/${n.root}`)}function ae(e,t){let n=L(),r=[];for(let o of e.visible()){if(q(o).kind==="unsupported")continue;if(!(o.menus??["palette"]).includes("palette"))continue;r.push({kind:"command",id:o.id,name:`${o.category}: ${o.title}`,detail:e.disabledReason(o.id)??"",chord:e.keymap.formatBinding(o.id)??"",enabled:e.isEnabled(o.id),recent:n.includes(o.id)})}let a=k(r,t.trim(),(o)=>o.name);if(t.trim()!=="")return a;let i=n.map((o)=>a.find((x)=>x.id===o)).filter((o)=>o!==void 0);return[...i,...a.filter((o)=>!i.includes(o))]}function ie(e){let t=u.value;if(!t)return[];let n=Nd(t.doc.document).map((r)=>({kind:"node",path:r.path,name:r.nodeType==="text"?String(r.node).slice(0,60):Zo(r.node),detail:r.nodeType}));return k(n,e.trim(),(r)=>r.name)}function se(){return P.filter((e)=>e.mode!=="picker").map((e)=>({kind:"mode",mode:e.mode,name:e.chip,detail:e.description,chord:e.prefix}))}function ce(e){let t=s,n=t.choices.map((r)=>({kind:"arg",commandId:t.command.id,argName:t.name,value:r.value,name:r.label,detail:`${t.command.title} → ${t.name}`}));return k(n,e.trim(),(r)=>r.name)}function de(){let{mode:e,query:t}=Q();if(s)return{rows:ce(t),showingRecent:!1};switch(e){case"commands":{let n=ne();return{rows:n?ae(n,t):[],showingRecent:t.trim()===""}}case"nodes":return{rows:ie(t),showingRecent:!1};case"projects":return{rows:re(t),showingRecent:t.trim()===""};case"picker":return{rows:se(),showingRecent:!1};default:return{rows:oe(t),showingRecent:t.trim()===""}}}function le(e){let t=E.find((n)=>e.startsWith(n.prefix));if(t)g=t.mode,d=e.slice(1);else d=e;if(c=0,e!==d)j().query=e;l(),C()}function pe(){g="picker",s=null,c=0,l()}function me(e){g=e,d="",c=0,l(),C()}function U(e,t){let n=ne();if(!n)return;ee(e.id),y(),on(n,e.id,t,"Palette")}function M(e){switch(e.kind){case"project":{y(),z?.openRecentProject(e.root);return}case"file":{y(),Ff({name:e.name,path:e.path,root:J()??""}),Lo(e.path);return}case"mode":{me(e.mode);return}case"node":{y(),Rc("selection.set",{path:e.path},"Palette");return}case"arg":{U(s.command,{[e.argName]:e.value});return}default:ue(e)}}function ue(e){let t=ne(),n=t?.get(e.id);if(!t||!n||!e.enabled)return;let r=q(n);if(r.kind==="choice"){s={choices:r.choices,command:n,name:r.name},d="",c=0,l();return}U(n)}function he(e){let t=e.split(".").pop()?.toLowerCase();if(t==="json")return"file-code";if(t&&Vs(t))return"file-text";return"file"}function fe(e){switch(e.kind){case"project":return"folder-open";case"file":return he(e.name);case"command":return"play";case"node":return"stack";default:return"caret-right"}}function ge(e,t){if((e.kind==="command"||e.kind==="mode")&&e.chord)return"chord";if(e.kind==="command"&&e.recent)return"recent";return t?"recent":"none"}function xe(e){switch(e.kind){case"project":return`project:${e.root}`;case"file":return`file:${e.path}`;case"command":return`command:${e.id}`;case"node":return`node:${e.path.join("/")}`;case"mode":return`mode:${e.mode}`;default:return`arg:${e.value}`}}function be(e,t){if(w)return"Reading the project's files…";if(t.trim()!=="")return"No results";switch(e){case"projects":return"No recent projects — open one to get started";case"nodes":return"Open a document to jump to its elements";case"commands":return"Type to find any command in Studio";default:return F(e).placeholder}}T("palette",N);var I=null,A=null,h=[];function j(){return I??=v({activate:()=>{let e=h[c];if(e)M(e)},activateRow:(e)=>{let t=h[Number(e)];if(t)M(t)},activeId:"",canClearMode:!1,chipLabel:"",clearMode:pe,close:y,emptyHint:"",expanded:!1,hasChip:!1,hover:(e)=>{c=e,j().activeId=S(e)},input:le,isEmpty:!0,move:(e)=>{if(h.length===0)return;c=Math.max(0,Math.min(c+e,h.length-1)),j().activeId=S(c)},open:!1,placeholder:"",query:"",rows:[],sectionLabel:"",showSection:!1}),I}function ve(){setTimeout(()=>{if(f)H().querySelector('[part="input"]')?.focus()},0)}function l(){let e=j();if(!A)A=R("palette",e,H());if(e.open=f,!f){h=[];return}let{mode:t,query:n}=Q(),{rows:r,showingRecent:a}=de(),i=F(t);h=r,e.placeholder=s?`Choose a ${s.name}…`:i.placeholder,e.hasChip=s!==null||t!=="picker",e.chipLabel=s?s.command.title:i.chip,e.query=d,e.canClearMode=d===""&&(s!==null||g!=="picker"),e.rows=r.map((o)=>({chord:(o.kind==="command"||o.kind==="mode")&&o.chord?o.chord:"",detail:o.detail,disabled:o.kind==="command"&&!o.enabled,icon:fe(o),key:xe(o),kind:o.kind,name:o.name,trailing:ge(o,a)})),e.expanded=r.length>0,e.activeId=r.length>0?S(c):"",e.isEmpty=r.length===0,e.emptyHint=be(t,n),e.showSection=a&&r.length>0,e.sectionLabel=s?`${s.command.title} — ${s.name}`:t==="projects"?"Recent projects":t==="commands"?"Recently used":"Recently opened"}
1
+ import{p}from"./studio-y7jehjrp.js";import{qt,Vs,Ka}from"./studio-cqmtbg2p.js";import{ne}from"./studio-cp1gbff9.js";import{T,R,on,Rc,vs}from"./studio-7qvs7v0m.js";import{v}from"./studio-fqq890ap.js";import{u}from"./studio-x5g1xk77.js";import{Xg,lE,Ff,Lo}from"./studio-hnvnfbdv.js";import{Nd,Zo,D}from"./studio-tp642n5g.js";var N={$schema:"https://jxsuite.com/schema/v1",$id:"StudioPalette",$description:'The command palette: a `role="combobox"` field over the kit\'s `jx-listbox`, whose rows are `jx-option`s the host projects. `rows` is the ranked set for the current mode and query; `activeId` is the highlight, and it is ONE string — the id the field points `aria-activedescendant` at and the id the listbox is handed as `active`, so a key moves the caret without the rows reconciling and no row re-decides its own flag. The FIELD is not a `jx-combobox`: this one carries a mode chip inside its box, its Enter runs a command rather than committing a value, and its panel is a centred scrim rather than a popover under a control. Every gesture calls back into panels/quick-search.ts, which owns the modes, the ranking, the recents and what a row does.',tagName:"div",attributes:{part:"palette"},style:{display:"contents",'& [part="overlay"]':{position:"fixed",inset:"0",zIndex:"1000",display:"flex",justifyContent:"center",paddingTop:"60px",background:"rgba(0, 0, 0, 0.4)"},'& [part="overlay"][hidden]':{display:"none"},'& [part="panel"]':{width:"560px",maxWidth:"calc(100vw - 32px)",maxHeight:"420px",display:"flex",flexDirection:"column",alignSelf:"flex-start",background:"var(--jx-bg-overlay)",border:"1px solid var(--jx-border)",borderRadius:"var(--jx-radius-md)",boxShadow:"var(--jx-shadow-dialog)",color:"var(--jx-fg)",fontFamily:"var(--jx-font-sans)",overflow:"hidden"},'& [part="input-row"]':{display:"flex",alignItems:"center",gap:"var(--jx-space-3)",paddingLeft:"var(--jx-space-4)",background:"var(--jx-bg-input)",borderBottom:"1px solid var(--jx-border)"},'& [part="chip-slot"], & [part="empty-slot"], & [part="section-slot"], & [part="trailing-slot"]':{display:"contents"},'& [part="chip"]':{display:"inline-flex",alignItems:"center",gap:"var(--jx-space-1)",flexShrink:"0",padding:"2px var(--jx-space-1) 2px var(--jx-space-3)",borderRadius:"var(--jx-radius-sm)",background:"var(--jx-accent-solid)",color:"var(--jx-accent-fg)",fontSize:"var(--jx-text-sm)"},'& [part="chip-remove"] > [part="control"]':{color:"inherit",opacity:"0.8",":hover":{opacity:"1",background:"transparent"}},'& [part="input"]':{flex:"1",minWidth:"0",padding:"var(--jx-space-4) var(--jx-space-5) var(--jx-space-4) var(--jx-space-1)",font:"inherit",fontSize:"var(--jx-text-lg)",border:"none",outline:"none",background:"none",color:"var(--jx-fg)","::placeholder":{color:"var(--jx-fg-muted)"},":focus-visible":{outline:"var(--jx-focus-ring)",outlineOffset:"-2px"}},'& [part="results"]':{$description:"The list is the kit's: a `jx-listbox` of `jx-option`, so the highlight is ONE id — `active`, the same string the field points `aria-activedescendant` at — and the listbox's sidecar is the single writer of every row's `selected`. What this surface still decides is density. The kit's row pads itself by `--jx-space-3`; the other half of the 16px optical margin the panel has always had sits here, on the list, so the heading, the rows and the empty sentence line up on one edge instead of each naming it.",flex:"1",paddingInline:"var(--jx-space-3)"},'& [part="option"] [part="label"]':{fontWeight:"500"},'& [part="option"] [part="description"]':{$description:"A `jx-select` row's note is a category at the END of the row, so the kit pushes it there with an auto margin. A palette row's note is a CONTINUATION of its name — the file's directory, the command's category — and the far edge belongs to the chord, which is how this surface teaches the keyboard it replaced. So the auto margin moves to the end slot.",marginInlineStart:"0"},'& [part="option"] [part="end"]':{marginInlineStart:"auto"},'& [part="option"][aria-disabled="true"]':{$description:"An unavailable command is greyed with its `requires` sentence as the subtitle, and that sentence is the reason the row is on screen at all. The kit fades the whole row to 0.45, which would take a muted grey below any readable contrast — so the row keeps its ink and only the name and the glyph dim.",opacity:"1"},'& [part="option"][aria-disabled="true"] [part="label"], & [part="option"][aria-disabled="true"] [part="icon"]':{opacity:"0.45"},'& [part="chord"]':{flexShrink:"0",fontFamily:"inherit",fontSize:"var(--jx-text-xs)",color:"var(--jx-fg-muted)",border:"1px solid var(--jx-border)",borderRadius:"var(--jx-radius-sm)",padding:"0 5px"},'& [part="option"][aria-selected="true"] [part="chord"]':{color:"inherit",borderColor:"currentColor"},'& [part="badge"]':{fontSize:"var(--jx-text-xs)",padding:"1px var(--jx-space-2)",borderRadius:"var(--jx-radius-sm)",background:"var(--jx-border)",color:"var(--jx-fg-dim)"},'& [part="hint"]':{padding:"var(--jx-space-2) var(--jx-space-5)",borderTop:"1px solid var(--jx-border)",color:"var(--jx-fg-muted)",fontSize:"var(--jx-text-xs)"},'& [part="hint"] kbd':{fontFamily:"inherit",color:"var(--jx-fg-dim)"}},children:[{tagName:"div",attributes:{part:"overlay",hidden:"${state.open ? null : ''}"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/close"},value:[]}]},children:[{tagName:"div",attributes:{part:"panel"},onclick:{$prototype:"Function",body:[{stopPropagation:!0}]},children:[{tagName:"div",attributes:{part:"input-row"},children:[{tagName:"span",attributes:{part:"chip-slot",role:"none"},$switch:{$ref:"#/state/hasChip"},cases:{true:{tagName:"span",attributes:{part:"chip"},children:[{tagName:"span",attributes:{part:"chip-label"},textContent:"${state.chipLabel}"},{tagName:"jx-action-button",$props:{label:"Clear mode",hint:"Clear mode (Backspace)",icon:"x",size:"sm"},attributes:{part:"chip-remove"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/clearMode"},value:[]}]}}]}}},{tagName:"input",attributes:{part:"input",type:"text",role:"combobox","aria-controls":"quick-search-listbox","aria-expanded":"${state.expanded ? 'true' : 'false'}","aria-activedescendant":"${state.activeId || null}","aria-autocomplete":"list","aria-label":"${state.placeholder}",placeholder:"${state.placeholder}"},value:{$ref:"#/state/query"},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/input"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{ArrowDown:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/move"},value:[1]}],ArrowUp:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/move"},value:[-1]}],Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/activate"},value:[]}],Escape:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/close"},value:[]}],Backspace:[{$switch:{$ref:"#/state/canClearMode"},cases:{true:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/clearMode"},value:[]}]}}]}}]}}]},{tagName:"jx-listbox",attributes:{part:"results",id:"quick-search-listbox"},$props:{label:"Results",active:"${state.activeId}"},onselect:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/activateRow"},value:[{$ref:"event#/detail"}]}],description:"One handler for every row, because a row's `select` bubbles. The detail is the row's `value`, which is the index it occupies in `rows` — the same number a hover names, and the number the id is built from."},children:[{tagName:"div",attributes:{part:"empty-slot",role:"none"},$switch:{$ref:"#/state/isEmpty"},cases:{true:{tagName:"div",attributes:{part:"empty"},textContent:"${state.emptyHint}"}}},{tagName:"div",attributes:{part:"section-slot",role:"none"},$switch:{$ref:"#/state/showSection"},cases:{true:{tagName:"div",attributes:{part:"group-heading"},textContent:"${state.sectionLabel}"}}},{$prototype:"Array",items:{$ref:"#/state/rows"},key:{$ref:"$map/item/key"},map:{tagName:"jx-option",attributes:{part:"option",id:"quick-search-option-${$map.index}","data-kind":"${$map.item.kind}"},$props:{value:"${$map.index}",label:{$ref:"$map/item/name"},description:{$ref:"$map/item/detail"},disabled:{$ref:"$map/item/disabled"}},onmouseenter:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/hover"},value:[{$ref:"$map/index"}]}]},children:[{tagName:"jx-icon",attributes:{slot:"icon"},$props:{name:{$ref:"$map/item/icon"}}},{tagName:"span",attributes:{slot:"end",part:"trailing-slot"},$switch:{$ref:"$map/item/trailing"},cases:{chord:{tagName:"kbd",attributes:{part:"chord"},textContent:"${$map.item.chord}"},recent:{tagName:"span",attributes:{part:"badge"},textContent:"recent"}}}]}}]},{tagName:"div",attributes:{part:"hint"},children:[{tagName:"kbd",textContent:"↑↓"}," move · ",{tagName:"kbd",textContent:"↵"}," run · ",{tagName:"kbd",textContent:"?"}," modes · ",{tagName:"kbd",textContent:">"}," commands · ",{tagName:"kbd",textContent:"@"}," elements"]}]}]}]};var P=[{mode:"files",prefix:"",chip:"Files",placeholder:"Go to a file…",description:"Open a file by any part of its path — pgblog finds pages/blog/index.md."},{mode:"commands",prefix:">",chip:"Commands",placeholder:"Run a command…",description:"Run anything Studio can do, with its keyboard shortcut printed beside it."},{mode:"nodes",prefix:"@",chip:"Symbols",placeholder:"Go to an element in this document…",description:"Select an element in the open document by its Outline name."},{mode:"projects",prefix:"",chip:"Recent Projects",placeholder:"Open a recent project…",description:"Reopen a project you have had open before."},{mode:"picker",prefix:"?",chip:"Modes",placeholder:"Type ? for modes, > for commands, @ for elements…",description:"List these modes."}],X=new Map(P.map((e)=>[e.mode,e])),E=P.filter((e)=>e.prefix!=="");function F(e){return X.get(e)??P[0]}function O(e,t,n){let r=E.find((i)=>t.startsWith(i.prefix));if(r)return O(r.mode,t.slice(1),n);let a=e;if(a==="picker"&&t.trim()!=="")a="files";if(a==="files"&&!n)a="projects";return{mode:a,query:t}}var Y=new Set(["/","-","_","."," "]);function V(e,t){if(t==="")return 0;let n=e.toLowerCase(),r=t.toLowerCase(),a=n.lastIndexOf("/")+1,i=0,o=0,x=-2;for(let G of r){let m=n.indexOf(G,o);if(m===-1)return null;if(m===x+1)i+=8;if(m===0||Y.has(n[m-1]??""))i+=6;if(m>=a)i+=4;x=m,o=m+1}return i-x*0.01-n.length*0.001}function k(e,t,n){let r=[];for(let[a,i]of e.entries()){let o=V(n(i),t);if(o!==null)r.push({index:a,item:i,score:o})}return r.toSorted((a,i)=>i.score-a.score||a.index-i.index).map((a)=>a.item)}function q(e){let t=e.args,n=t?.properties;if(!t||!n)return{kind:"none"};let r=Object.keys(n);if(r.length!==1)return{kind:"unsupported"};let a=r[0],i=n[a];if(i.enum)return{kind:"choice",name:a,choices:i.enum.map((o)=>({label:String(o),value:o}))};if(i.type==="boolean")return{kind:"choice",name:a,choices:[{label:"on",value:!0},{label:"off",value:!1}]};return{kind:"unsupported"}}function S(e){return`quick-search-option-${e}`}var _="jx-studio-recent-commands",Z=6;function L(){try{let e=JSON.parse(localStorage.getItem(_)||"[]");return Array.isArray(e)?e.filter((t)=>typeof t==="string"):[]}catch{return[]}}function ee(e){let t=[e,...L().filter((n)=>n!==e)].slice(0,Z);try{localStorage.setItem(_,JSON.stringify(t))}catch{}}var z=null,f=!1,g="picker",d="",c=0,b=null,w=!1,s=null;function H(){return vs("popover","quick-search")}function P_(e){z=e??null}function $f(e="files"){f=!0,g=e,d="",c=0,s=null,b=null,l(),ve(),C()}function y(){f=!1,s=null,l()}function J(){return D?D.projectRoot??null:null}function B(){return D!=null}function Q(){return O(g,d,B())}function W(e){let t=e.split("/");return t.pop(),t.length>0?t.join("/"):""}function te(e){if(e.startsWith("/home/"))return`~/${e.split("/").slice(3).join("/")}`;return e}async function C(){if(!f||b!==null||w||!B())return;w=!0,l();try{await qt(),b=(await p().searchFiles("",Ka())).map((t)=>({kind:"file",path:t.path,name:t.name??t.path.split("/").pop()??"",detail:W(t.path),recent:!1}))}catch{b=[]}w=!1,l()}function oe(e){if(e.trim()==="")return lE(J()??void 0).map((t)=>({kind:"file",path:t.path,name:t.name,detail:W(t.path),recent:!0}));return k(b??[],e.trim(),(t)=>t.path)}function re(e){let t=Xg().map((n)=>({kind:"project",root:n.root,name:n.name,detail:te(n.root)}));return k(t,e.trim(),(n)=>`${n.name}/${n.root}`)}function ae(e,t){let n=L(),r=[];for(let o of e.visible()){if(q(o).kind==="unsupported")continue;if(!(o.menus??["palette"]).includes("palette"))continue;r.push({kind:"command",id:o.id,name:`${o.category}: ${o.title}`,detail:e.disabledReason(o.id)??"",chord:e.keymap.formatBinding(o.id)??"",enabled:e.isEnabled(o.id),recent:n.includes(o.id)})}let a=k(r,t.trim(),(o)=>o.name);if(t.trim()!=="")return a;let i=n.map((o)=>a.find((x)=>x.id===o)).filter((o)=>o!==void 0);return[...i,...a.filter((o)=>!i.includes(o))]}function ie(e){let t=u.value;if(!t)return[];let n=Nd(t.doc.document).map((r)=>({kind:"node",path:r.path,name:r.nodeType==="text"?String(r.node).slice(0,60):Zo(r.node),detail:r.nodeType}));return k(n,e.trim(),(r)=>r.name)}function se(){return P.filter((e)=>e.mode!=="picker").map((e)=>({kind:"mode",mode:e.mode,name:e.chip,detail:e.description,chord:e.prefix}))}function ce(e){let t=s,n=t.choices.map((r)=>({kind:"arg",commandId:t.command.id,argName:t.name,value:r.value,name:r.label,detail:`${t.command.title} → ${t.name}`}));return k(n,e.trim(),(r)=>r.name)}function de(){let{mode:e,query:t}=Q();if(s)return{rows:ce(t),showingRecent:!1};switch(e){case"commands":{let n=ne();return{rows:n?ae(n,t):[],showingRecent:t.trim()===""}}case"nodes":return{rows:ie(t),showingRecent:!1};case"projects":return{rows:re(t),showingRecent:t.trim()===""};case"picker":return{rows:se(),showingRecent:!1};default:return{rows:oe(t),showingRecent:t.trim()===""}}}function le(e){let t=E.find((n)=>e.startsWith(n.prefix));if(t)g=t.mode,d=e.slice(1);else d=e;if(c=0,e!==d)j().query=e;l(),C()}function pe(){g="picker",s=null,c=0,l()}function me(e){g=e,d="",c=0,l(),C()}function U(e,t){let n=ne();if(!n)return;ee(e.id),y(),on(n,e.id,t,"Palette")}function M(e){switch(e.kind){case"project":{y(),z?.openRecentProject(e.root);return}case"file":{y(),Ff({name:e.name,path:e.path,root:J()??""}),Lo(e.path);return}case"mode":{me(e.mode);return}case"node":{y(),Rc("selection.set",{path:e.path},"Palette");return}case"arg":{U(s.command,{[e.argName]:e.value});return}default:ue(e)}}function ue(e){let t=ne(),n=t?.get(e.id);if(!t||!n||!e.enabled)return;let r=q(n);if(r.kind==="choice"){s={choices:r.choices,command:n,name:r.name},d="",c=0,l();return}U(n)}function he(e){let t=e.split(".").pop()?.toLowerCase();if(t==="json")return"file-code";if(t&&Vs(t))return"file-text";return"file"}function fe(e){switch(e.kind){case"project":return"folder-open";case"file":return he(e.name);case"command":return"play";case"node":return"stack";default:return"caret-right"}}function ge(e,t){if((e.kind==="command"||e.kind==="mode")&&e.chord)return"chord";if(e.kind==="command"&&e.recent)return"recent";return t?"recent":"none"}function xe(e){switch(e.kind){case"project":return`project:${e.root}`;case"file":return`file:${e.path}`;case"command":return`command:${e.id}`;case"node":return`node:${e.path.join("/")}`;case"mode":return`mode:${e.mode}`;default:return`arg:${e.value}`}}function be(e,t){if(w)return"Reading the project's files…";if(t.trim()!=="")return"No results";switch(e){case"projects":return"No recent projects — open one to get started";case"nodes":return"Open a document to jump to its elements";case"commands":return"Type to find any command in Studio";default:return F(e).placeholder}}T("palette",N);var I=null,A=null,h=[];function j(){return I??=v({activate:()=>{let e=h[c];if(e)M(e)},activateRow:(e)=>{let t=h[Number(e)];if(t)M(t)},activeId:"",canClearMode:!1,chipLabel:"",clearMode:pe,close:y,emptyHint:"",expanded:!1,hasChip:!1,hover:(e)=>{c=e,j().activeId=S(e)},input:le,isEmpty:!0,move:(e)=>{if(h.length===0)return;c=Math.max(0,Math.min(c+e,h.length-1)),j().activeId=S(c)},open:!1,placeholder:"",query:"",rows:[],sectionLabel:"",showSection:!1}),I}function ve(){setTimeout(()=>{if(f)H().querySelector('[part="input"]')?.focus()},0)}function l(){let e=j();if(!A)A=R("palette",e,H());if(e.open=f,!f){h=[];return}let{mode:t,query:n}=Q(),{rows:r,showingRecent:a}=de(),i=F(t);h=r,e.placeholder=s?`Choose a ${s.name}…`:i.placeholder,e.hasChip=s!==null||t!=="picker",e.chipLabel=s?s.command.title:i.chip,e.query=d,e.canClearMode=d===""&&(s!==null||g!=="picker"),e.rows=r.map((o)=>({chord:(o.kind==="command"||o.kind==="mode")&&o.chord?o.chord:"",detail:o.detail,disabled:o.kind==="command"&&!o.enabled,icon:fe(o),key:xe(o),kind:o.kind,name:o.name,trailing:ge(o,a)})),e.expanded=r.length>0,e.activeId=r.length>0?S(c):"",e.isEmpty=r.length===0,e.emptyHint=be(t,n),e.showSection=a&&r.length>0,e.sectionLabel=s?`${s.command.title} — ${s.name}`:t==="projects"?"Recent projects":t==="commands"?"Recently used":"Recently opened"}
2
2
  export{P_,$f};
3
3
 
4
4
  //# debugId=8C60334715637D6264756E2164756E21
5
- //# sourceMappingURL=studio-eh0rac07.js.map
5
+ //# sourceMappingURL=studio-rr4xkv81.js.map
@@ -1,5 +1,5 @@
1
- import{te}from"./studio-ery42sqr.js";import{p}from"./studio-y7jehjrp.js";import{v,k}from"./studio-fqq890ap.js";import{fd,Tu}from"./studio-xy3tv3az.js";import{Zi,T,R}from"./studio-spf2skgc.js";import{dd}from"./studio-01qza1n3.js";import{EE}from"./studio-56z7evx4.js";import{$b}from"./studio-ceb34dxj.js";import{kd}from"./studio-zpnk016a.js";import{D}from"./studio-tp642n5g.js";var N={$schema:"https://jxsuite.com/schema/v1",$id:"StudioSettingsContributed",$description:'The generic settings section behind `$studio.settings` (specs/extensions.md §9.1), as a Jx document over the kit. One document serves both layouts an extension may declare: "form" is a single schema form over the whole section value, "map" is master-detail — the entry keys on the left, the selected entry\'s form on the right. The adapter (`surfaces/settings-contributed.ts`) hands in the title, the layout, the entry rows already marked as selected, and whatever the reader is part-way through typing; `settings/contributed-section.ts` decides what an entry may be named, what reaches `project.json`, and what the validator said about it. The schema form itself is an ISLAND: this document renders `form-host` and nothing inside it, because a form built from a JSON Schema is `ui/schema-form.ts`\'s surface rather than this one\'s — the section places the element that surface hands back. The actions row is the second island: `panels/data-grid.ts` contributes it, and that one is still lit over Spectrum.',tagName:"section",attributes:{part:"contributed"},style:{$description:"What `.settings-section-title`, `.settings-two-col`, `.settings-list-panel`, `.settings-editor-panel`, `.settings-editor-header`, `.settings-empty-state` and `.settings-inline-form` said in `styles/overlays.css`, keyed on `part` and re-pointed at the studio token layer. This section was the LAST emitter of every one of them except `.settings-empty-state`, which `panels/settings-pane.ts` still writes when a project closes with the editor open — so those rules are dead in the stylesheet from here, and a central sweep removes them rather than this change, which owns no stylesheet. Two values could not come across. `.settings-editor-header h3` read `var(--spectrum-font-size-100, 14px)`, and a document is mounted in the pane rather than inside `<sp-theme>`, so it would have taken its hard-coded fallback every time; the entry name is a kit textfield now and carries the kit's own type ramp. And `.entry-name-input`, `.settings-form-panel`, `.settings-section` and `.contributed-section` had no rule anywhere at all — they were four entries on `check-styles.ts`'s orphan ledger, which is the ledger's point.",display:"block",'& [part="title"]':{margin:"0 0 16px",fontSize:"16px",fontWeight:"600",color:"var(--fg)"},'& [part="actions"]':{$description:"The host-contributed actions row — Test Connection, Push Schema, Open Data Grid on the data sections. `.data-section-actions` never had a rule anywhere, so the row was whatever the buttons stacked up to; it is a row with a gap under it now.",display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},'& [part="columns"]':{$description:"The 1px gap over the border colour is the divider between the two columns: two panels on `--bg-panel` with `--border` showing through the gap, so nothing draws a rule of its own.",display:"flex",height:"100%",gap:"1px",background:"var(--border)"},'& [part="list"]':{display:"flex",flexDirection:"column",gap:"4px",padding:"12px",width:"200px",minWidth:"200px",background:"var(--bg-panel)",overflowY:"auto"},'& [part="entry"], & [part="new-open"]':{width:"100%"},'& [part="entry"] > [part="control"], & [part="new-open"] > [part="control"]':{$description:"`.settings-list-panel sp-action-button` said `width: 100%; justify-content: flex-start`, and both halves belong to the button the row is made of rather than to the row: a kit action button centres its glyph and its label, which reads as a list of centred names.",width:"100%",justifyContent:"flex-start"},'& [part="new-form"]':{display:"flex",alignItems:"center",gap:"6px"},'& [part="new-field"]':{flex:"1",minWidth:"0"},'& [part="empty"]':{flex:"1",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",color:"var(--fg-dim)",fontSize:"13px"},'& [part="editor"]':{$description:"`min-width: 0` is the one line `.settings-editor-panel` did not have and needed: a flex child's floor is its content, and the schema form inside this one is a whole form rather than the short cards Data Shapes puts here — so a long pointer or a wide row pushed the column past the right edge of the pane instead of scrolling inside it.",flex:"1",padding:"16px",background:"var(--bg-panel)",overflowY:"auto",minWidth:"0"},'& [part="editor-header"]':{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},'& [part="entry-name"]':{flex:"1",minWidth:"0",maxWidth:"220px"}},children:[{tagName:"h3",attributes:{part:"title"},textContent:"${state.title}"},{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/actionsState"},cases:{slot:{$description:"An island: the host renders its own actions into this node and the document renders nothing inside it.",tagName:"div",attributes:{part:"actions"}}}},{tagName:"div",attributes:{part:"body-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/layout"},cases:{form:{$description:"An island: `ui/schema-form.ts` draws the whole section value into this node.",tagName:"div",attributes:{part:"form-host"}},map:{tagName:"div",attributes:{part:"columns"},children:[{tagName:"div",attributes:{part:"list"},children:[{$prototype:"Array",items:{$ref:"#/state/entries"},key:{$ref:"$map/item/key"},map:{tagName:"jx-action-button",attributes:{part:"entry","data-entry":"${$map.item.key}","data-jx-region":"${$map.item.region}"},$props:{label:"${$map.item.key}",selected:{$ref:"$map/item/selected"},quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"$map/item/key"}]}]},children:[{tagName:"span",textContent:"${$map.item.key}"}]}},{tagName:"div",attributes:{part:"new-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/newState"},cases:{closed:{tagName:"jx-action-button",attributes:{part:"new-open"},$props:{label:"New Entry",icon:"plus",quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openNew"},value:[]}]},children:[{tagName:"span",textContent:"New Entry"}]},open:{tagName:"div",attributes:{part:"new-form"},children:[{tagName:"jx-textfield",attributes:{part:"new-field"},$props:{label:"New entry name",placeholder:"entry-name",size:"sm",value:{$ref:"#/state/newName"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/editNew"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/createNew"},value:[]}],Escape:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/cancelNew"},value:[]}]}}]}},{tagName:"jx-button",attributes:{part:"new-create"},$props:{size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/createNew"},value:[]}]},children:[{tagName:"span",textContent:"Create"}]}]}}}]},{tagName:"div",attributes:{part:"editor-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/editorState"},cases:{empty:{tagName:"div",attributes:{part:"empty"},textContent:"Select or create an entry"},editing:{tagName:"div",attributes:{part:"editor","data-jx-region":"${state.editorRegion}"},children:[{tagName:"div",attributes:{part:"editor-header"},children:[{tagName:"jx-textfield",attributes:{part:"entry-name"},$props:{label:"Entry name",size:"sm",value:{$ref:"#/state/entryName"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/renameEntry"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{Enter:[{operator:"call",target:{$ref:"#/state/renameEntry"},value:[{$ref:"event#/target/value"}]}],Escape:[{operator:"call",target:{$ref:"#/state/cancelRename"},value:[{$ref:"event#/target/value"}]}]}}]}},{tagName:"jx-action-button",attributes:{part:"delete-entry"},$props:{label:"Delete entry",hint:"Delete entry",icon:"trash",quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/removeEntry"},value:[]}]}}]},{$description:"An island: `ui/schema-form.ts` draws the selected entry into this node.",tagName:"div",attributes:{part:"form-host"}}]}}}]}}}]};T("settings-contributed",N);function V(){return{actionsState:"none",editorRegion:"",editorState:"empty",entries:[],entryName:"",layout:"form",newName:"",newState:"closed",title:""}}function W(e){let o=e?.attributes?.part;return typeof o==="string"?o:""}function j(e,i,o){e.textContent="";let n=v({...V(),...i}),t=null,r=!1,a=R("settings-contributed",n,e,{onNodeCreated:(s,l,d)=>{if(!(s instanceof HTMLElement))return;let c=W(d);if(c==="form-host")o.formSlot(s);else if(c==="actions")o.actionsSlot(s)}}).then((s)=>{if(r)return s.dispose(),s.root;return t=s,s.root});return{attached:()=>{if(r)return!1;let s=t?.root;return s===void 0?!0:s instanceof HTMLElement&&e.contains(s)},dispose(){r=!0,t?.dispose(),t=null},host:e,ready:a,update(s){n.actionsState=s.actionsState,n.editorRegion=s.editorRegion,n.editorState=s.editorState,n.entries=s.entries,n.entryName=s.entryName,n.layout=s.layout,n.newName=s.newName,n.newState=s.newState,n.title=s.title}}}var f=new Map,b=new Set,w=new Map;function kE(e,i){let o=D?.projectConfig?.[e],n=o&&typeof o==="object"&&!Array.isArray(o)?o:{};if(!Object.hasOwn(n,i))return Object.keys(n);return f.set(e,i),null}var x=new Map;function I(e,i){let o={},n=[];for(let t of i){let r=t.indexOf(": "),a=r===-1?"":t.slice(0,r),s=r===-1?t:t.slice(r+2);if(a===e){n.push(s);continue}if(!a.startsWith(`${e}/`))continue;let[l]=a.slice(e.length+1).split("/");if(l&&o[l]===void 0)o[l]=s}return{fields:o,section:n}}async function S(e,i){let o=D.projectConfig;if(!(await kd()).ok)return;let t=[];try{t=await dd(o)}catch(r){k.warn(`Could not validate project.json — ${te(r)}`,{key:"settings:validator",path:"project.json",source:"Settings",tier:"problem"});return}x.set(e,I(e,t).fields),i()}function E(e,i){for(let[o,n]of Object.entries(i))if(n===void 0)delete e[o];else e[o]=n}function H(e){return e.toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z0-9-]/g,"")}function J(e,i){if(!e)return{};let o=(n)=>{if(typeof n==="string")return n.replaceAll("${key}",i);if(Array.isArray(n))return n.map((t)=>o(t));if(n&&typeof n==="object"){let t={};for(let[r,a]of Object.entries(n))t[r]=o(a);return t}return n};return o(e)}function M(e,i,o=null){let n=p();return{fieldKeyPrefix:`$settings.${e}`,resolvePointer:(t,r)=>Tu(t,{projectConfig:D?.projectConfig??{},...r!==void 0&&{scope:r},...i.formats!==void 0&&{formats:i.formats}}),...typeof n.setSecrets==="function"?{commitSecret:async(t,r)=>{let a=EE(e,o,t);return await n.setSecrets({set:{[a]:r}}),a}}:{}}}function h(e){let i=D?.projectConfig;if(!i)return null;let o=i[e];if(o&&typeof o==="object"&&!Array.isArray(o))return o;let n={};return i[e]=n,n}var A=new WeakMap;function m(e){w1(e.container,e.contribution,e.opts)}function O(e,i){e.echo=i,m(e)}function K(e){let{container:i,contribution:o,opts:n}=e,t=o.key,r=o.title??t,a=n.actions?"slot":"none",s=$b(i),l=Zi(s,"editor");if((o.settings.layout??"form")!=="map")return{actionsState:a,editorRegion:l,editorState:"empty",entries:[],entryName:"",layout:"form",newName:"",newState:"closed",title:r};let d=h(t)??{},c=f.get(t)??null,g=c===null?void 0:d[c],y=c!==null&&g!==void 0&&g!==null&&typeof g==="object";return{actionsState:a,editorRegion:l,editorState:y?"editing":"empty",entries:Object.keys(d).map((u)=>({key:u,region:Zi(s,`entry:${u}`),selected:u===c})),entryName:e.echo??(y?c:""),layout:"map",newName:w.get(t)??"",newState:b.has(t)?"open":"closed",title:r}}function L(e){let i=e.formHost;if(!i)return;let{contribution:o,opts:n}=e,t=o.key,r=o.settings.entry?.ui,a=()=>m(e),s=(u)=>{if(u.parentNode!==i)i.replaceChildren(u)};if((o.settings.layout??"form")!=="map"){let u=`/${t}`;s(fd(`section:${t}`,o.entrySchema,h(t)??{},{context:M(t,n,null),errors:x.get(u)??{},onChange:(P)=>{let C=h(t);if(!C)return;E(C,P),a(),S(u,a)},rerender:a,...r!==void 0&&{ui:r}}));return}let l=h(t)??{},d=f.get(t)??null,c=d===null?void 0:l[d];if(d===null||!c||typeof c!=="object"){i.replaceChildren();return}let g=c,y=`/${t}/${d}`;s(fd(`section:${t}:${d}`,o.entrySchema,g,{context:M(t,n,d),errors:x.get(y)??{},onChange:(u)=>{E(g,u),a(),S(y,a)},rerender:a,...r!==void 0&&{ui:r}}))}function F(e){let i=e.actionsHost,{actions:o}=e.opts;if(!i)return;if(!o){i.replaceChildren();return}let n=e.contribution.key,t=(e.contribution.settings.layout??"form")==="map"?f.get(n)??null:null;o(i,{rerender:()=>m(e),sectionKey:n,selected:t})}function q(e){let i=(t)=>{e.echo=null,m(e),S(t,()=>m(e))},o=()=>{e.echo=null,m(e)},n=()=>e.contribution.key;return{cancelNew(){b.delete(n()),w.delete(n()),m(e)},cancelRename(t){O(e,t),o()},createNew(){let t=n(),r=H(w.get(t)??""),a=h(t);if(!r||!a||a[r])return;a[r]=J(e.contribution.settings.entry?.newEntry,r),f.set(t,r),b.delete(t),w.delete(t),i(`/${t}`)},editNew(t){w.set(n(),t),m(e)},openNew(){b.add(n()),m(e)},removeEntry(){let t=n(),r=f.get(t)??null,a=h(t);if(!r||!a?.[r])return;delete a[r],f.set(t,null),i(`/${t}`)},renameEntry(t){O(e,t);let r=n(),a=f.get(r)??null,s=h(r),l=H(t.trim());if(!a||!s||!l||l===a||s[l]){o();return}let d={};for(let[c,g]of Object.entries(s))d[c===a?l:c]=g,delete s[c];Object.assign(s,d),f.set(r,l),i(`/${r}`)},select(t){f.set(n(),t),e.echo=null,m(e)}}}function w1(e,i,o={}){let n=A.get(e);if(n)n.contribution=i,n.opts=o;if(!n?.handle.attached()){n?.handle.dispose();let t={actionsHost:null,container:e,contribution:i,echo:null,formHost:null,handle:void 0,opts:o};A.set(e,t),t.handle=j(e,q(t),{actionsSlot:(r)=>{t.actionsHost=r,F(t)},formSlot:(r)=>{t.formHost=r,L(t)}}),n=t}n.handle.update(K(n)),F(n),L(n)}
1
+ import{te}from"./studio-ery42sqr.js";import{p}from"./studio-y7jehjrp.js";import{v,k}from"./studio-fqq890ap.js";import{fd,Tu}from"./studio-zev8ssp1.js";import{Zi,T,R}from"./studio-7qvs7v0m.js";import{dd}from"./studio-01qza1n3.js";import{EE}from"./studio-3ck2a5c4.js";import{$b}from"./studio-5gs9th4b.js";import{kd}from"./studio-4m50vh74.js";import{D}from"./studio-tp642n5g.js";var N={$schema:"https://jxsuite.com/schema/v1",$id:"StudioSettingsContributed",$description:'The generic settings section behind `$studio.settings` (specs/extensions.md §9.1), as a Jx document over the kit. One document serves both layouts an extension may declare: "form" is a single schema form over the whole section value, "map" is master-detail — the entry keys on the left, the selected entry\'s form on the right. The adapter (`surfaces/settings-contributed.ts`) hands in the title, the layout, the entry rows already marked as selected, and whatever the reader is part-way through typing; `settings/contributed-section.ts` decides what an entry may be named, what reaches `project.json`, and what the validator said about it. The schema form itself is an ISLAND: this document renders `form-host` and nothing inside it, because a form built from a JSON Schema is `ui/schema-form.ts`\'s surface rather than this one\'s — the section places the element that surface hands back. The actions row is the second island: `panels/data-grid.ts` contributes it, and that one is still lit over Spectrum.',tagName:"section",attributes:{part:"contributed"},style:{$description:"What `.settings-section-title`, `.settings-two-col`, `.settings-list-panel`, `.settings-editor-panel`, `.settings-editor-header`, `.settings-empty-state` and `.settings-inline-form` said in `styles/overlays.css`, keyed on `part` and re-pointed at the studio token layer. This section was the LAST emitter of every one of them except `.settings-empty-state`, which `panels/settings-pane.ts` still writes when a project closes with the editor open — so those rules are dead in the stylesheet from here, and a central sweep removes them rather than this change, which owns no stylesheet. Two values could not come across. `.settings-editor-header h3` read `var(--spectrum-font-size-100, 14px)`, and a document is mounted in the pane rather than inside `<sp-theme>`, so it would have taken its hard-coded fallback every time; the entry name is a kit textfield now and carries the kit's own type ramp. And `.entry-name-input`, `.settings-form-panel`, `.settings-section` and `.contributed-section` had no rule anywhere at all — they were four entries on `check-styles.ts`'s orphan ledger, which is the ledger's point.",display:"block",'& [part="title"]':{margin:"0 0 16px",fontSize:"16px",fontWeight:"600",color:"var(--fg)"},'& [part="actions"]':{$description:"The host-contributed actions row — Test Connection, Push Schema, Open Data Grid on the data sections. `.data-section-actions` never had a rule anywhere, so the row was whatever the buttons stacked up to; it is a row with a gap under it now.",display:"flex",alignItems:"center",flexWrap:"wrap",gap:"8px",marginBottom:"12px"},'& [part="columns"]':{$description:"The 1px gap over the border colour is the divider between the two columns: two panels on `--bg-panel` with `--border` showing through the gap, so nothing draws a rule of its own.",display:"flex",height:"100%",gap:"1px",background:"var(--border)"},'& [part="list"]':{display:"flex",flexDirection:"column",gap:"4px",padding:"12px",width:"200px",minWidth:"200px",background:"var(--bg-panel)",overflowY:"auto"},'& [part="entry"], & [part="new-open"]':{width:"100%"},'& [part="entry"] > [part="control"], & [part="new-open"] > [part="control"]':{$description:"`.settings-list-panel sp-action-button` said `width: 100%; justify-content: flex-start`, and both halves belong to the button the row is made of rather than to the row: a kit action button centres its glyph and its label, which reads as a list of centred names.",width:"100%",justifyContent:"flex-start"},'& [part="new-form"]':{display:"flex",alignItems:"center",gap:"6px"},'& [part="new-field"]':{flex:"1",minWidth:"0"},'& [part="empty"]':{flex:"1",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-panel)",color:"var(--fg-dim)",fontSize:"13px"},'& [part="editor"]':{$description:"`min-width: 0` is the one line `.settings-editor-panel` did not have and needed: a flex child's floor is its content, and the schema form inside this one is a whole form rather than the short cards Data Shapes puts here — so a long pointer or a wide row pushed the column past the right edge of the pane instead of scrolling inside it.",flex:"1",padding:"16px",background:"var(--bg-panel)",overflowY:"auto",minWidth:"0"},'& [part="editor-header"]':{display:"flex",alignItems:"center",gap:"12px",marginBottom:"16px"},'& [part="entry-name"]':{flex:"1",minWidth:"0",maxWidth:"220px"}},children:[{tagName:"h3",attributes:{part:"title"},textContent:"${state.title}"},{tagName:"div",attributes:{part:"actions-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/actionsState"},cases:{slot:{$description:"An island: the host renders its own actions into this node and the document renders nothing inside it.",tagName:"div",attributes:{part:"actions"}}}},{tagName:"div",attributes:{part:"body-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/layout"},cases:{form:{$description:"An island: `ui/schema-form.ts` draws the whole section value into this node.",tagName:"div",attributes:{part:"form-host"}},map:{tagName:"div",attributes:{part:"columns"},children:[{tagName:"div",attributes:{part:"list"},children:[{$prototype:"Array",items:{$ref:"#/state/entries"},key:{$ref:"$map/item/key"},map:{tagName:"jx-action-button",attributes:{part:"entry","data-entry":"${$map.item.key}","data-jx-region":"${$map.item.region}"},$props:{label:"${$map.item.key}",selected:{$ref:"$map/item/selected"},quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/select"},value:[{$ref:"$map/item/key"}]}]},children:[{tagName:"span",textContent:"${$map.item.key}"}]}},{tagName:"div",attributes:{part:"new-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/newState"},cases:{closed:{tagName:"jx-action-button",attributes:{part:"new-open"},$props:{label:"New Entry",icon:"plus",quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/openNew"},value:[]}]},children:[{tagName:"span",textContent:"New Entry"}]},open:{tagName:"div",attributes:{part:"new-form"},children:[{tagName:"jx-textfield",attributes:{part:"new-field"},$props:{label:"New entry name",placeholder:"entry-name",size:"sm",value:{$ref:"#/state/newName"}},oninput:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/editNew"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{Enter:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/createNew"},value:[]}],Escape:[{preventDefault:!0},{operator:"call",target:{$ref:"#/state/cancelNew"},value:[]}]}}]}},{tagName:"jx-button",attributes:{part:"new-create"},$props:{size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/createNew"},value:[]}]},children:[{tagName:"span",textContent:"Create"}]}]}}}]},{tagName:"div",attributes:{part:"editor-slot",role:"none"},style:{display:"contents"},$switch:{$ref:"#/state/editorState"},cases:{empty:{tagName:"div",attributes:{part:"empty"},textContent:"Select or create an entry"},editing:{tagName:"div",attributes:{part:"editor","data-jx-region":"${state.editorRegion}"},children:[{tagName:"div",attributes:{part:"editor-header"},children:[{tagName:"jx-textfield",attributes:{part:"entry-name"},$props:{label:"Entry name",size:"sm",value:{$ref:"#/state/entryName"}},onchange:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/renameEntry"},value:[{$ref:"event#/target/value"}]}]},onkeydown:{$prototype:"Function",body:[{$switch:{$ref:"event#/key"},cases:{Enter:[{operator:"call",target:{$ref:"#/state/renameEntry"},value:[{$ref:"event#/target/value"}]}],Escape:[{operator:"call",target:{$ref:"#/state/cancelRename"},value:[{$ref:"event#/target/value"}]}]}}]}},{tagName:"jx-action-button",attributes:{part:"delete-entry"},$props:{label:"Delete entry",hint:"Delete entry",icon:"trash",quiet:!0,size:"sm"},onclick:{$prototype:"Function",body:[{operator:"call",target:{$ref:"#/state/removeEntry"},value:[]}]}}]},{$description:"An island: `ui/schema-form.ts` draws the selected entry into this node.",tagName:"div",attributes:{part:"form-host"}}]}}}]}}}]};T("settings-contributed",N);function V(){return{actionsState:"none",editorRegion:"",editorState:"empty",entries:[],entryName:"",layout:"form",newName:"",newState:"closed",title:""}}function W(e){let o=e?.attributes?.part;return typeof o==="string"?o:""}function j(e,i,o){e.textContent="";let n=v({...V(),...i}),t=null,r=!1,a=R("settings-contributed",n,e,{onNodeCreated:(s,l,d)=>{if(!(s instanceof HTMLElement))return;let c=W(d);if(c==="form-host")o.formSlot(s);else if(c==="actions")o.actionsSlot(s)}}).then((s)=>{if(r)return s.dispose(),s.root;return t=s,s.root});return{attached:()=>{if(r)return!1;let s=t?.root;return s===void 0?!0:s instanceof HTMLElement&&e.contains(s)},dispose(){r=!0,t?.dispose(),t=null},host:e,ready:a,update(s){n.actionsState=s.actionsState,n.editorRegion=s.editorRegion,n.editorState=s.editorState,n.entries=s.entries,n.entryName=s.entryName,n.layout=s.layout,n.newName=s.newName,n.newState=s.newState,n.title=s.title}}}var f=new Map,b=new Set,w=new Map;function kE(e,i){let o=D?.projectConfig?.[e],n=o&&typeof o==="object"&&!Array.isArray(o)?o:{};if(!Object.hasOwn(n,i))return Object.keys(n);return f.set(e,i),null}var x=new Map;function I(e,i){let o={},n=[];for(let t of i){let r=t.indexOf(": "),a=r===-1?"":t.slice(0,r),s=r===-1?t:t.slice(r+2);if(a===e){n.push(s);continue}if(!a.startsWith(`${e}/`))continue;let[l]=a.slice(e.length+1).split("/");if(l&&o[l]===void 0)o[l]=s}return{fields:o,section:n}}async function S(e,i){let o=D.projectConfig;if(!(await kd()).ok)return;let t=[];try{t=await dd(o)}catch(r){k.warn(`Could not validate project.json — ${te(r)}`,{key:"settings:validator",path:"project.json",source:"Settings",tier:"problem"});return}x.set(e,I(e,t).fields),i()}function E(e,i){for(let[o,n]of Object.entries(i))if(n===void 0)delete e[o];else e[o]=n}function H(e){return e.toLowerCase().replaceAll(/\s+/g,"-").replaceAll(/[^a-z0-9-]/g,"")}function J(e,i){if(!e)return{};let o=(n)=>{if(typeof n==="string")return n.replaceAll("${key}",i);if(Array.isArray(n))return n.map((t)=>o(t));if(n&&typeof n==="object"){let t={};for(let[r,a]of Object.entries(n))t[r]=o(a);return t}return n};return o(e)}function M(e,i,o=null){let n=p();return{fieldKeyPrefix:`$settings.${e}`,resolvePointer:(t,r)=>Tu(t,{projectConfig:D?.projectConfig??{},...r!==void 0&&{scope:r},...i.formats!==void 0&&{formats:i.formats}}),...typeof n.setSecrets==="function"?{commitSecret:async(t,r)=>{let a=EE(e,o,t);return await n.setSecrets({set:{[a]:r}}),a}}:{}}}function h(e){let i=D?.projectConfig;if(!i)return null;let o=i[e];if(o&&typeof o==="object"&&!Array.isArray(o))return o;let n={};return i[e]=n,n}var A=new WeakMap;function m(e){w1(e.container,e.contribution,e.opts)}function O(e,i){e.echo=i,m(e)}function K(e){let{container:i,contribution:o,opts:n}=e,t=o.key,r=o.title??t,a=n.actions?"slot":"none",s=$b(i),l=Zi(s,"editor");if((o.settings.layout??"form")!=="map")return{actionsState:a,editorRegion:l,editorState:"empty",entries:[],entryName:"",layout:"form",newName:"",newState:"closed",title:r};let d=h(t)??{},c=f.get(t)??null,g=c===null?void 0:d[c],y=c!==null&&g!==void 0&&g!==null&&typeof g==="object";return{actionsState:a,editorRegion:l,editorState:y?"editing":"empty",entries:Object.keys(d).map((u)=>({key:u,region:Zi(s,`entry:${u}`),selected:u===c})),entryName:e.echo??(y?c:""),layout:"map",newName:w.get(t)??"",newState:b.has(t)?"open":"closed",title:r}}function L(e){let i=e.formHost;if(!i)return;let{contribution:o,opts:n}=e,t=o.key,r=o.settings.entry?.ui,a=()=>m(e),s=(u)=>{if(u.parentNode!==i)i.replaceChildren(u)};if((o.settings.layout??"form")!=="map"){let u=`/${t}`;s(fd(`section:${t}`,o.entrySchema,h(t)??{},{context:M(t,n,null),errors:x.get(u)??{},onChange:(P)=>{let C=h(t);if(!C)return;E(C,P),a(),S(u,a)},rerender:a,...r!==void 0&&{ui:r}}));return}let l=h(t)??{},d=f.get(t)??null,c=d===null?void 0:l[d];if(d===null||!c||typeof c!=="object"){i.replaceChildren();return}let g=c,y=`/${t}/${d}`;s(fd(`section:${t}:${d}`,o.entrySchema,g,{context:M(t,n,d),errors:x.get(y)??{},onChange:(u)=>{E(g,u),a(),S(y,a)},rerender:a,...r!==void 0&&{ui:r}}))}function F(e){let i=e.actionsHost,{actions:o}=e.opts;if(!i)return;if(!o){i.replaceChildren();return}let n=e.contribution.key,t=(e.contribution.settings.layout??"form")==="map"?f.get(n)??null:null;o(i,{rerender:()=>m(e),sectionKey:n,selected:t})}function q(e){let i=(t)=>{e.echo=null,m(e),S(t,()=>m(e))},o=()=>{e.echo=null,m(e)},n=()=>e.contribution.key;return{cancelNew(){b.delete(n()),w.delete(n()),m(e)},cancelRename(t){O(e,t),o()},createNew(){let t=n(),r=H(w.get(t)??""),a=h(t);if(!r||!a||a[r])return;a[r]=J(e.contribution.settings.entry?.newEntry,r),f.set(t,r),b.delete(t),w.delete(t),i(`/${t}`)},editNew(t){w.set(n(),t),m(e)},openNew(){b.add(n()),m(e)},removeEntry(){let t=n(),r=f.get(t)??null,a=h(t);if(!r||!a?.[r])return;delete a[r],f.set(t,null),i(`/${t}`)},renameEntry(t){O(e,t);let r=n(),a=f.get(r)??null,s=h(r),l=H(t.trim());if(!a||!s||!l||l===a||s[l]){o();return}let d={};for(let[c,g]of Object.entries(s))d[c===a?l:c]=g,delete s[c];Object.assign(s,d),f.set(r,l),i(`/${r}`)},select(t){f.set(n(),t),e.echo=null,m(e)}}}function w1(e,i,o={}){let n=A.get(e);if(n)n.contribution=i,n.opts=o;if(!n?.handle.attached()){n?.handle.dispose();let t={actionsHost:null,container:e,contribution:i,echo:null,formHost:null,handle:void 0,opts:o};A.set(e,t),t.handle=j(e,q(t),{actionsSlot:(r)=>{t.actionsHost=r,F(t)},formSlot:(r)=>{t.formHost=r,L(t)}}),n=t}n.handle.update(K(n)),F(n),L(n)}
2
2
  export{kE,w1};
3
3
 
4
4
  //# debugId=4A09A7801D85A2D264756E2164756E21
5
- //# sourceMappingURL=studio-f195h2hq.js.map
5
+ //# sourceMappingURL=studio-tmeq6mjb.js.map