@hazem3500/palette 0.9.145 → 0.9.147

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 (63) hide show
  1. package/cli/design-edit.mjs +17 -1
  2. package/dist/accent-picker-B5LQWAPK.js +1 -0
  3. package/dist/account-tokens-ZMRW3JYS.js +1 -0
  4. package/dist/{chunk-5JHJGDSP.js → chunk-5MFM5GPR.js} +1 -1
  5. package/dist/{chunk-5TP5P77H.js → chunk-A75MS3NI.js} +1 -1
  6. package/dist/chunk-BKIUQ7QJ.js +1 -0
  7. package/dist/{chunk-2JHO4ZDE.js → chunk-EWC2YAAK.js} +1 -1
  8. package/dist/chunk-GAHDL7C2.js +1 -0
  9. package/dist/chunk-MKWOTTCN.js +1 -0
  10. package/dist/chunk-QALADLZS.js +1 -0
  11. package/dist/{chunk-UWTBLOTJ.js → chunk-TFFPX3O4.js} +1 -1
  12. package/dist/{chunk-SQH6FIXB.js → chunk-TJBTE5VK.js} +1 -1
  13. package/dist/color-editor-BRURQZA7.js +1 -0
  14. package/dist/design-comment-A433M6JL.js +1 -0
  15. package/dist/design-comment.d.ts +4 -0
  16. package/dist/design-export-5QM7HHRT.js +1 -0
  17. package/dist/design-export.d.ts +10 -4
  18. package/dist/design-geometry-XO6RM4YB.js +1 -0
  19. package/dist/design-mode.js +1 -1
  20. package/dist/design-spacing-YL6QH2P3.js +1 -0
  21. package/dist/design-spacing.d.ts +23 -0
  22. package/dist/frame-iframe-ZLYVQEQD.js +1 -0
  23. package/dist/index.js +1 -1
  24. package/dist/{inline-text-editor-2K7YELB6.js → inline-text-editor-RSHGHTFR.js} +1 -1
  25. package/dist/node.mjs +1 -1
  26. package/dist/onboarding-2TITOWW3.js +1 -0
  27. package/dist/pin-groups-J24YDQIU.js +1 -0
  28. package/dist/pin-move-HKUATGE2.js +1 -0
  29. package/dist/react-props-panel-IUOMUL2Z.js +1 -0
  30. package/dist/react.js +1 -1
  31. package/dist/review-layout.d.ts +16 -4
  32. package/dist/server.js +1 -1
  33. package/dist/setup.js +1 -1
  34. package/dist/shortcut-help-M45D4PUL.js +1 -0
  35. package/dist/snapshot-annotate-DMJKY2I6.js +1 -0
  36. package/dist/thread-snapshot-PQJ6QIUN.js +1 -0
  37. package/dist/token-custom-QUDSPT6I.js +1 -0
  38. package/dist/token-page-LLR4EMEC.js +1 -0
  39. package/dist/token-picker-76CU4ZP5.js +1 -0
  40. package/dist/toolbar-runtime-RKA2HVCZ.js +1 -0
  41. package/package.json +1 -1
  42. package/server/setup-client.txt +109 -68
  43. package/dist/accent-picker-2SDJUWFU.js +0 -1
  44. package/dist/account-tokens-ZZYU6CPG.js +0 -1
  45. package/dist/chunk-B5MDOH7H.js +0 -1
  46. package/dist/chunk-D2E65BP7.js +0 -1
  47. package/dist/chunk-QFONAD5S.js +0 -1
  48. package/dist/color-editor-D3KUEQLZ.js +0 -1
  49. package/dist/design-comment-FO6ZJ3DP.js +0 -1
  50. package/dist/design-export-N6WWIQXA.js +0 -1
  51. package/dist/design-geometry-4GK7D57Z.js +0 -1
  52. package/dist/frame-iframe-FFHZB3T6.js +0 -1
  53. package/dist/onboarding-BQ4BDKUS.js +0 -1
  54. package/dist/pin-groups-677GE533.js +0 -1
  55. package/dist/pin-move-TASTN2BX.js +0 -1
  56. package/dist/react-props-panel-NPOEFJCV.js +0 -1
  57. package/dist/shortcut-help-ZBS3ALR6.js +0 -1
  58. package/dist/snapshot-annotate-25A74DZZ.js +0 -1
  59. package/dist/thread-snapshot-DVL3GSVL.js +0 -1
  60. package/dist/token-custom-S3637QZ2.js +0 -1
  61. package/dist/token-page-Q73LPPMT.js +0 -1
  62. package/dist/token-picker-B32ZAZ3X.js +0 -1
  63. package/dist/toolbar-runtime-PNP3WOJM.js +0 -1
@@ -271,8 +271,20 @@ export function designEditFromProse(body, selector) {
271
271
  // Token values from the Tokens view apply page-wide, so they target :root.
272
272
  if (header[1] === "token") target ||= ":root";
273
273
  let layout = "";
274
+ // A suggestion's fenced diff: `- prop: before;` / `+ prop: after;` lines inside the rule block.
275
+ let fence = false;
276
+ const diff = { before: new Map(), after: new Map() };
274
277
  for (const line of lines.slice(1)) {
275
- if (line.startsWith("Target: ")) target ||= line.slice(8).trim();
278
+ if (fence) {
279
+ if (/^```/.test(line)) fence = false;
280
+ else {
281
+ const declaration = /^([-+])\s+([\w-]+)\s*:\s*(.*?);?\s*$/.exec(line);
282
+ if (declaration) diff[declaration[1] === "-" ? "before" : "after"].set(declaration[2], declaration[3]);
283
+ }
284
+ continue;
285
+ }
286
+ if (header[1] === "style" && /^```diff\s*$/.test(line)) fence = true;
287
+ else if (line.startsWith("Target: ")) target ||= line.slice(8).trim();
276
288
  else if (header[1] === "geometry") {
277
289
  if (line.startsWith("Layout: ")) layout = line.slice(8).trim().slice(0, 200);
278
290
  // "- Move Button “Save”: from Toolbar (3rd) → Sidebar (1st)", then "From: …" and "To: …" lines.
@@ -302,6 +314,10 @@ export function designEditFromProse(body, selector) {
302
314
  if (item && JSON.stringify(item.from) !== JSON.stringify(item.to)) changes.push(item);
303
315
  }
304
316
  }
317
+ for (const [property, to] of diff.after) {
318
+ const from = diff.before.get(property);
319
+ if (from !== to) changes.push({ kind: "css", property, from: from ?? "", to });
320
+ }
305
321
  }
306
322
  // A move line without its From and To lines can't be applied; keep the rest of the edit.
307
323
  for (let index = changes.length - 1; index >= 0; index--)
@@ -0,0 +1 @@
1
+ import{i as e,j as t}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";import{useEffect as r,useLayoutEffect as n,useRef as o,useState as a}from"react";import{createRoot as c}from"react-dom/client";import l,{useRef as i,useMemo as u,useEffect as s,useState as f,useCallback as d,useLayoutEffect as h}from"react";function p(){return(p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function v(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(o[r]=e[r]);return o}function m(e){var t=i(e),r=i(function(e){t.current&&t.current(e)});return t.current=e,r.current}var g=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1),e>r?r:e<t?t:e},b=function(e){return"touches"in e},_=function(e){return e&&e.ownerDocument.defaultView||self},w=function(e,t,r){var n=e.getBoundingClientRect(),o=b(t)?function(e,t){for(var r=0;r<e.length;r++)if(e[r].identifier===t)return e[r];return e[0]}(t.touches,r):t;return{left:g((o.pageX-(n.left+_(e).pageXOffset))/n.width),top:g((o.pageY-(n.top+_(e).pageYOffset))/n.height)}},x=function(e){!b(e)&&e.preventDefault()},C=l.memo(function(e){var t=e.onMove,r=e.onKey,n=e.onEnd,o=v(e,["onMove","onKey","onEnd"]),a=i(null),c=m(t),f=m(r),d=m(n),h=i(null),g=i(!1),C=u(function(){var e=function(e){x(e),(b(e)?e.touches.length>0:e.buttons>0)&&a.current?c(w(a.current,e,h.current)):(r(!1),d())},t=function(){r(!1),d()};function r(r){var n=g.current,o=_(a.current),c=r?o.addEventListener:o.removeEventListener;c(n?"touchmove":"mousemove",e),c(n?"touchend":"mouseup",t)}return[function(e){var t,n=e.nativeEvent,o=a.current;if(o&&(x(n),t=n,(!g.current||b(t))&&o)){if(b(n)){g.current=!0;var l=n.changedTouches||[];l.length&&(h.current=l[0].identifier)}o.focus(),c(w(o,n,h.current)),r(!0)}},function(e){var t=e.which||e.keyCode;t<37||t>40||(e.preventDefault(),f({left:39===t?.05:37===t?-.05:0,top:40===t?.05:38===t?-.05:0}))},function(e){var t=e.which||e.keyCode;t>=37&&t<=40&&d()},r]},[f,c,d]),E=C[0],y=C[1],k=C[2],N=C[3];return s(function(){return N},[N]),l.createElement("div",p({},o,{onTouchStart:E,onMouseDown:E,className:"react-colorful__interactive",ref:a,onKeyDown:y,onKeyUp:k,tabIndex:0,role:"slider"}))}),E=function(e){return e.filter(Boolean).join(" ")},y=function(e){var t=e.color,r=e.left,n=e.top,o=void 0===n?.5:n,a=E(["react-colorful__pointer",e.className]);return l.createElement("div",{className:a,style:{top:100*o+"%",left:100*r+"%"}},l.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:t}}))},k=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=Math.pow(10,t)),Math.round(r*e)/r},N=(Math.PI,function(e){return"#"===e[0]&&(e=e.substring(1)),e.length<6?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?k(parseInt(e[3]+e[3],16)/255,2):1}:{r:parseInt(e.substring(0,2),16),g:parseInt(e.substring(2,4),16),b:parseInt(e.substring(4,6),16),a:8===e.length?k(parseInt(e.substring(6,8),16)/255,2):1}}),M=function(e){var t=function(e){var t=e.s,r=e.v,n=e.a,o=(200-t)*r/100;return{h:k(e.h),s:k(o>0&&o<200?t*r/100/(o<=100?o:200-o)*100:0),l:k(o/2),a:k(n,2)}}(e);return"hsl("+t.h+", "+t.s+"%, "+t.l+"%)"},L=function(e){var t=e.h,r=e.s,n=e.v,o=e.a;t=t/360*6,r/=100,n/=100;var a=Math.floor(t),c=n*(1-r),l=n*(1-(t-a)*r),i=n*(1-(1-t+a)*r),u=a%6;return{r:k(255*[n,l,c,c,i,n][u]),g:k(255*[i,n,n,l,c,c][u]),b:k(255*[c,c,i,n,n,l][u]),a:k(o,2)}},j=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},D=function(e){var t=e.r,r=e.g,n=e.b,o=e.a,a=o<1?j(k(255*o)):"";return"#"+j(t)+j(r)+j(n)+a},H=function(e){var t=e.r,r=e.g,n=e.b,o=e.a,a=Math.max(t,r,n),c=a-Math.min(t,r,n),l=c?a===t?(r-n)/c:a===r?2+(n-t)/c:4+(t-r)/c:0;return{h:60*(l<0?l+6:l),s:a?c/a*100:0,v:a/255*100,a:o}},P=l.memo(function(e){var t=e.hue,r=e.onChange,n=e.onChangeEnd,o=E(["react-colorful__hue",e.className]);return l.createElement("div",{className:o},l.createElement(C,{onMove:function(e){r({h:360*e.left})},onKey:function(e){r({h:g(t+360*e.left,0,360)})},onEnd:n,"aria-label":"Hue","aria-valuenow":k(t),"aria-valuemax":"360","aria-valuemin":"0"},l.createElement(y,{className:"react-colorful__hue-pointer",left:t/360,color:M({h:t,s:100,v:100,a:1})})))}),z=l.memo(function(e){var t=e.hsva,r=e.onChange,n=e.onChangeEnd,o={backgroundColor:M({h:t.h,s:100,v:100,a:1})};return l.createElement("div",{className:"react-colorful__saturation",style:o},l.createElement(C,{onMove:function(e){r({s:100*e.left,v:100-100*e.top})},onKey:function(e){r({s:g(t.s+100*e.left,0,100),v:g(t.v-100*e.top,0,100)})},onEnd:n,"aria-label":"Color","aria-valuetext":"Saturation "+k(t.s)+"%, Brightness "+k(t.v)+"%"},l.createElement(y,{className:"react-colorful__saturation-pointer",top:1-t.v/100,left:t.s/100,color:M(t)})))}),I=function(e,t){if(e===t)return!0;for(var r in e)if(e[r]!==t[r])return!1;return!0};var A=typeof window<"u"?h:s,B=new WeakMap,O=function(e){A(function(){var t=e.current;if(typeof document<"u"&&t){var r=t.getRootNode?t.getRootNode():t.ownerDocument,n=r&&("head"in r||"host"in r)?r:t.ownerDocument;if(!B.has(n)){var o="head"in n?n.head:n,a=(o.ownerDocument||document).createElement("style");a.innerHTML='.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url(\'data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>\')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}';var c=typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0;c&&a.setAttribute("nonce",c),B.set(n,a),o.appendChild(a)}}},[])},S=function(e){var t=e.className,r=e.colorModel,n=e.color,o=void 0===n?r.defaultColor:n,a=e.onChange,c=e.onChangeEnd,u=v(e,["className","colorModel","color","onChange","onChangeEnd"]),h=i(null);O(h);var g=function(e,t,r,n){var o=m(r),a=m(n),c=f(function(){return e.toHsva(t)}),l=c[0],u=c[1],h=i({color:t,hsva:l}),p=i(!1);s(function(){if(!e.equal(t,h.current.color)){var r=e.toHsva(t);h.current={hsva:r,color:t},u(r),p.current=!1}},[t,e]),s(function(){var t;I(l,h.current.hsva)||e.equal(t=e.fromHsva(l),h.current.color)||(h.current={hsva:l,color:t},o(t),p.current=!0)},[l,e,o]);var v=d(function(e){u(function(t){return Object.assign({},t,e)})},[]),g=d(function(){p.current&&(p.current=!1,a(h.current.color))},[a]);return[l,v,g]}(r,o,a,c),b=g[0],_=g[1],w=g[2],x=E(["react-colorful",t]);return l.createElement("div",p({},u,{ref:h,className:x}),l.createElement(z,{hsva:b,onChange:_,onChangeEnd:w}),l.createElement(P,{hue:b.h,onChange:_,onChangeEnd:w,className:"react-colorful__last-control"}))},K={defaultColor:"000",toHsva:function(e){return H(N(e))},fromHsva:function(e){return function(e){return D(L(e))}({h:e.h,s:e.s,v:e.v,a:1})},equal:function(e,t){return e.toLowerCase()===t.toLowerCase()||I(N(e),N(t))}},R=function(e){return l.createElement(S,p({},e,{colorModel:K}))},T=/^#?([0-9A-F]{3,8})$/i,W=function(e){var t=e.color,r=void 0===t?"":t,n=e.onChange,o=e.onBlur,a=e.escape,c=e.validate,i=e.format,u=e.process,h=v(e,["color","onChange","onBlur","escape","validate","format","process"]),g=f(function(){return a(r)}),b=g[0],_=g[1],w=m(n),x=m(o),C=d(function(e){var t=a(e.target.value);_(t),c(t)&&w(u?u(t):t)},[a,u,c,w]),E=d(function(e){c(e.target.value)||_(a(r)),x(e)},[r,a,c,x]);return s(function(){_(a(r))},[r,a]),l.createElement("input",p({},h,{value:i?i(b):b,spellCheck:"false",onChange:C,onBlur:E}))},q=function(e){return"#"+e},$=function(e){var t=e.prefixed,r=e.alpha,n=v(e,["prefixed","alpha"]),o=d(function(e){return e.replace(/([^0-9A-F]+)/gi,"").substring(0,r?8:6)},[r]),a=d(function(e){return t=e,n=r,o=T.exec(t),3===(a=o?o[1].length:0)||6===a||!!n&&4===a||!!n&&8===a;var t,n,o,a},[r]);return l.createElement(W,p({},n,{escape:o,format:t?q:void 0,process:q,validate:a}))};import*as Y from"react";var F=({size:e=24,color:t="currentColor",...r})=>Y.createElement("svg",{viewBox:"0 0 24 24",width:e,height:e,stroke:t,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...r},Y.createElement("path",{d:"M12 5v14m-7-7h14"}));F.displayName="Plus";import{jsx as X,jsxs as G}from"react/jsx-runtime";var Q=[["Lavender","#c8b5f4"],["Blue","#85b5ff"],["Mint","#84d9bb"],["Yellow","#f4d779"],["Peach","#f5af87"],["Pink","#efa5c6"]];function U({initial:t,onChange:c}){let[l,i]=a(t),[u,s]=a(!1),f=o(null),d=o(null),h=!Q.some(([,e])=>e===l),p=e=>{if(!/^#[0-9a-f]{6}$/i.test(e))return;let t=e.toLowerCase();i(t),c(t)};return n(()=>{let e=f.current;if(!e)return;if(!u){let t=window.setTimeout(()=>e.hidePopover(),150);return()=>clearTimeout(t)}e.showPopover();let t=()=>{let t=d.current.getBoundingClientRect();e.style.left=`${Math.max(8,Math.min(t.right-e.offsetWidth,innerWidth-e.offsetWidth-8))}px`,e.style.top=`${Math.max(8,t.top-e.offsetHeight-8)}px`};return t(),e.querySelector('[role="slider"]')?.focus({preventScroll:!0}),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[u]),r(()=>{if(!u)return;let t=new AbortController;return e(d.current,"pointerdown",e=>{!e.composedPath().includes(f.current)&&!e.composedPath().includes(d.current)&&s(!1)},{signal:t.signal}),()=>t.abort()},[u]),G("div",{className:"account-accent",children:[X("span",{className:"account-accent-label",children:"Accent color"}),G("div",{className:"accent-swatches",role:"group","aria-label":"Accent color",children:[Q.map(([e,t])=>X("button",{type:"button",className:"accent-swatch","aria-label":e,title:e,"aria-pressed":l===t,style:{"--swatch":t},onClick:()=>{p(t),s(!1)}},e)),X("button",{ref:d,type:"button",className:"accent-swatch accent-custom","aria-label":"Custom accent color","aria-haspopup":"dialog","aria-expanded":u,"aria-pressed":h,onClick:()=>s(!u),children:X(F,{"aria-hidden":"true"})})]}),G("div",{ref:f,popover:"manual",role:"dialog","aria-label":"Custom accent color",className:u?"accent-popover t-dropdown is-open":"accent-popover t-dropdown is-closing",onKeyDown:e=>{e.stopPropagation(),"Escape"===e.key&&(e.preventDefault(),s(!1),d.current?.focus())},children:[G("div",{className:"accent-popover-head",children:[X("span",{children:"Color"}),X("span",{children:l})]}),G("div",{className:"accent-picker-body",children:[X(R,{color:l,onChange:p}),X($,{"aria-label":"Hex accent color",className:"accent-hex",color:l,onChange:p,prefixed:!0})]})]})]})}function V(e,r){let n=t("div","account-accent-mount"),o=c(n);return o.render(X(U,{initial:e,onChange:r})),{element:n,destroy:()=>o.unmount()}}export{V as accentPicker};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-HHUTDVTM.js";import"./chunk-5HZI7HRR.js";import{d as t,j as n,k as o,l as a}from"./chunk-QALADLZS.js";import"./chunk-GAHDL7C2.js";var i=864e5,r=[["7 days",7],["30 days",30],["90 days",90],["1 year",365],["Never",null]],s={"comments:read":"Read","comments:write":"Write"},p=[["year",365*i],["month",30*i],["week",7*i],["day",i],["hour",36e5],["minute",6e4]];function d(e,t=Date.now()){let n=e-t,o=new Intl.RelativeTimeFormat(void 0,{numeric:"auto",style:"short"});for(let[e,t]of p)if(Math.abs(n)>=t)return o.format(Math.round(n/t),e);return"just now"}var l=e=>new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e),c=0;function u(i,p,u){let k=n("div","account account-tokens");k.setAttribute("role","region");let f=n("style");f.textContent=".account-layer .account.account-tokens{padding-top:16px;gap:16px}\n.api-tokens-head{display:flex;align-items:center;gap:6px;margin-right:36px;min-height:30px}\n.api-tokens-head h2{margin:0;font-size:15px;font-weight:500;letter-spacing:-.01em}\n.api-tokens-head h2:focus{outline:none}\n.account-layer .account .api-tokens-back{border-radius:8px;color:#bbb}\n.api-tokens-back svg{rotate:90deg;width:16px;height:16px}\n.api-tokens-back:hover{background:color-mix(in oklab,var(--mm-ink) 7%,transparent);color:var(--mm-ink)}\n.api-tokens-lede,.api-tokens-note{margin:0;font-size:12px;line-height:1.5;color:#999}\n.api-tokens-note code,.api-token-id{font:11px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#aaa;overflow-wrap:anywhere}\n.api-tokens-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}\n.api-token,.api-tokens-sheet,.api-tokens-empty{display:grid;gap:8px;padding:14px;border-radius:14px;background:#ffffff05;box-shadow:inset 0 0 0 1px #ffffff09;font-size:12px;color:#ddd}\n.api-tokens-empty{gap:4px;color:#999;text-align:center;padding:20px 14px}\n.api-tokens-empty strong{color:#ddd;font-weight:500}\n.api-token-row{display:flex;align-items:center;gap:8px;min-width:0}\n.api-token-row strong{font-weight:500;color:#eee;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}\n.api-token-chips{display:flex;flex-wrap:wrap;gap:4px}\n.api-token-chip{padding:0 6px;border-radius:5px;background:color-mix(in oklab,var(--mm-ink) 9%,transparent);color:color-mix(in oklab,var(--mm-ink) 78%,transparent);font-size:10px;font-weight:500;line-height:18px;white-space:nowrap}\n.api-token-chip[data-tone=warn]{background:#f1b77d1f;color:#f1b77d}\n.api-token-meta{display:flex;flex-wrap:wrap;gap:2px 10px;margin:0;color:#909090;font-size:11px}\n.api-token-meta div{display:flex;gap:4px}\n.api-token-meta dd{margin:0;color:#bbb}\n.api-token-meta time{cursor:default}\n.account-layer .account .api-token-revoke{margin-left:auto;padding:4px 8px;min-height:26px;border-radius:7px;font-size:11px;background:transparent;color:#fda29b}\n.api-token-revoke:hover,.api-tokens-actions .api-tokens-danger:hover{background:#fda29b14}\n.api-token-confirm{display:grid;gap:8px;padding-top:8px;box-shadow:0 -1px #ffffff0b}\n.api-token-confirm p,.api-tokens-sheet p{margin:0;line-height:1.5;color:#bbb}\n.api-tokens-actions{display:flex;justify-content:flex-end;gap:8px}\n.account-layer .account .api-tokens-actions button{width:auto;min-height:32px;padding:6px 12px;border-radius:9px;font-size:12px}\n.account-layer .account .api-tokens-actions .api-tokens-danger{background:#fda29b1a;color:#fda29b}\n.api-tokens-sheet{gap:14px;padding:16px}\n.api-tokens-sheet h3{margin:0;font-size:13px;font-weight:500;color:#eee}\n.api-tokens-sheet fieldset{border:0;margin:0;padding:0;display:grid;gap:8px;min-width:0}\n.api-tokens-sheet legend{padding:0;margin-bottom:8px;font-size:12px;color:#999}\n.account-layer .account .api-tokens-sheet input[type=text]{min-height:38px;padding:8px 10px;font-size:13px;border-radius:10px}\n.api-tokens-choices{display:flex;flex-wrap:wrap;gap:6px}\n.api-tokens-choice{position:relative;display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:9px;background:#ffffff06;box-shadow:inset 0 0 0 1px #ffffff0b;color:#bbb;cursor:pointer;font-size:12px;line-height:16px}\n.api-tokens-choice:hover{color:#eee}\n.account-layer .account .api-tokens-choice input{position:absolute;inset:0;width:100%;height:100%;min-height:0;margin:0;opacity:0;cursor:pointer}\n.api-tokens-choice:has(input:checked){background:#bda6ef24;box-shadow:inset 0 0 0 1px #bda6ef80;color:#eee}\n.api-tokens-choice:has(input:focus-visible){outline:2px solid #bda6ef;outline-offset:2px}\n.api-tokens-choice small{color:#888;font-size:10px}\n.api-tokens-sheet p.api-tokens-error,.api-tokens-error{margin:0;color:#fda29b;font-size:12px;line-height:1.5}\n.api-tokens-error:empty{display:none}\n.api-tokens-secret{display:flex;gap:8px;align-items:center}\n.api-tokens-secret code{flex:1;min-width:0;padding:8px 10px;border-radius:10px;background:#00000040;box-shadow:inset 0 0 0 1px #ffffff0b;font:11px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#eee;overflow-wrap:anywhere;user-select:all}\n.account-layer .account .api-tokens-secret button{width:auto;min-height:34px;padding:0 12px;font-size:12px}\n.api-tokens-secret svg{width:14px;height:14px}\n.api-tokens-warning{display:flex;gap:7px;align-items:flex-start}\n.api-tokens-warning svg{flex:none;width:13px;height:13px;margin-top:2px;color:#f1b77d}\n.api-tokens-skeleton{height:84px;border-radius:14px;background:linear-gradient(90deg,#ffffff05,#ffffff0d,#ffffff05) 0 0/200% 100%;animation:api-tokens-shimmer 1.4s linear infinite}\n@keyframes api-tokens-shimmer{to{background-position:-200% 0}}\n@media (prefers-reduced-motion:reduce){.api-tokens-skeleton{animation:none}}";let m=n("div","api-tokens-head"),h=a("Back to account",()=>R(),"icon api-tokens-back","chevron"),g=n("h2","","API tokens");g.id="api-tokens-"+ ++c,g.tabIndex=-1,g.dataset.focusKey="api-tokens-title",k.setAttribute("aria-labelledby",g.id),m.append(h,g);let x=n("p","api-tokens-lede","Let bots and CI read or write comments as you. Treat tokens like passwords."),y=n("p","sr-only");y.setAttribute("role","status"),y.setAttribute("aria-live","polite");let b=n("div"),v=n("div"),w=n("div","morphing-menu__tooltip sidebar-tooltip");w.setAttribute("aria-hidden","true"),k.append(f,m,x,b,v,y,w),h.dataset.focusKey="api-tokens-back";let A=null,C=null,T=!1,$=!1,j="",E=null,S=new Map,N=e=>{y.textContent="",setTimeout(()=>y.textContent=e,30)},I=e=>{t()||e.animate([{opacity:0,transform:"translateY(4px)"},{opacity:1,transform:"none"}],{duration:250,easing:"cubic-bezier(.22,1,.36,1)"})},K=e=>requestAnimationFrame(()=>k.querySelector(`[data-focus-key="${e}"]`)?.focus()),L=t=>t instanceof e&&404===t.status?"This Palette server doesn’t support API tokens.":t instanceof Error?t.message:"Something went wrong. Try again.";k.focusStart=()=>K("api-tokens-title"),k.dispose=()=>{D(),w.remove()};let R=()=>{k.dispose(),u()};k.addEventListener("keydown",e=>{if("Escape"===e.key)if(e.stopPropagation(),e.preventDefault(),j){let e=j;j="",U(),K(`api-tokens-revoke-${e}`)}else E?K("api-tokens-done"):T?F():R()});let z=0,D=()=>{clearTimeout(z),delete w.dataset.open};k.addEventListener("pointerover",e=>{let t=e.target.closest?.("[data-tip]");if(!t)return D();clearTimeout(z),z=window.setTimeout(()=>{if(!t.isConnected)return;let e=k.getRootNode();w.parentNode!==e&&e instanceof ShadowRoot&&e.append(w);let n=t.getBoundingClientRect();w.textContent=t.dataset.tip??"";let o=w.offsetWidth/2;w.style.left=`${Math.max(8+o,Math.min(document.documentElement.clientWidth-8-o,n.left+n.width/2))}px`,w.style.top=n.top-8-w.offsetHeight+"px",w.dataset.open="true"},w.dataset.open?0:400)}),k.addEventListener("pointerleave",k.dispose),k.addEventListener("pointerdown",k.dispose);let P=(e,t,o)=>{let a=n("div"),i=n("dd");if(null===t)i.textContent=o;else{let e=n("time","",d(t));e.dateTime=new Date(t).toISOString(),e.dataset.tip=l(t),i.append(e,n("span","sr-only",` (${l(t)})`))}return a.append(n("dt","",e),i),a},q=(e,t,o)=>{let a=n("span","api-token-chip",e);return t&&(a.dataset.tone=t),o&&(a.dataset.tip=o),a},M=e=>e?1===e.length&&e[0]===p?"This project":1===e.length?e[0]:`${e.length} projects`:"All projects";function H(t){let o=n("li","api-token");o.dataset.token=t.id;let r=n("div","api-token-row"),p=n("strong","",t.name);p.id=`api-token-${t.id}-${g.id}`,o.setAttribute("aria-labelledby",p.id),r.append(p),t.expired&&r.append(q("Expired","warn"));let d=a(`Revoke ${t.name}`,()=>{j=t.id,S.delete(t.id),U(),K(`api-tokens-keep-${t.id}`)},"api-token-revoke");d.textContent="Revoke",d.removeAttribute("title"),d.dataset.focusKey=`api-tokens-revoke-${t.id}`,d.disabled=j===t.id,r.append(d);let l=n("div","api-token-chips");for(let e of t.scopes)l.append(q(s[e]??e,"",e));l.append(q(M(t.projects),"",t.projects?.join(", ")??"Every project you can access"));let c=n("dl","api-token-meta");c.append(P("Created",t.createdAt,""),P("Last used",t.lastUsedAt,"Never"),P(t.expired?"Expired":"Expires",t.expiresAt,"Never")),o.append(r,n("code","api-token-id",`${t.prefix}…${t.last4}`),l,c);let u=S.get(t.id);if(u){let e=n("p","api-tokens-error",u);e.setAttribute("role","alert"),o.append(e)}if(j===t.id){let r=n("div","api-token-confirm");r.setAttribute("role","group"),r.setAttribute("aria-label",`Revoke ${t.name}`);let s=n("div","api-tokens-actions"),p=a("Keep token",()=>{j="",U(),K(`api-tokens-revoke-${t.id}`)},"secondary");p.dataset.focusKey=`api-tokens-keep-${t.id}`;let d=a("Revoke token",()=>{!async function(t){if(!A)return;let n=A,o=n.tokens.findIndex(e=>e.id===t.id);if(o<0)return;n.tokens.splice(o,1),j="",U();let a=n.tokens[o]??n.tokens[o-1];K(a?`api-tokens-revoke-${a.id}`:"api-tokens-new");try{await i.request(`account/tokens/${encodeURIComponent(t.id)}`,"DELETE"),N(`Revoked ${t.name}.`)}catch(a){if(a instanceof e&&404===a.status)return void N(`Revoked ${t.name}.`);if(A!==n)return;n.tokens.splice(Math.min(o,n.tokens.length),0,t),S.set(t.id,`Couldn’t revoke: ${L(a)}`),U(),N(`Couldn’t revoke ${t.name}.`),K(`api-tokens-revoke-${t.id}`)}}(t)},"secondary api-tokens-danger");d.dataset.focusKey=`api-tokens-confirm-${t.id}`,s.append(p,d),r.append(n("p","","Anything using this token stops working right away. This can’t be undone."),s),o.append(r),I(r)}return o}function F(){T=!1,U(),K("api-tokens-new")}let Y="";function U(){D();let t=A?E?"secret":T?"form":"list":C?"error":"loading",d=[];if(A&&"list"===t){let e=a("New token",()=>{T=!0,U(),K("api-tokens-name")},"secondary");e.replaceChildren(o("plus"),document.createTextNode("New token")),e.removeAttribute("title"),e.dataset.focusKey="api-tokens-new",d.push(e)}else A&&"form"===t?d.push(function(t){let o=n("form","api-tokens-sheet");o.noValidate=!0,o.setAttribute("aria-labelledby",`${g.id}-new`);let d=n("h3","","New token");d.id=`${g.id}-new`;let l=n("label","account-name-label","Name"),c=n("input");c.type="text",c.maxLength=60,c.required=!0,c.autocomplete="off",c.placeholder="e.g. Deploy bot",c.dataset.focusKey="api-tokens-name",l.append(c);let u=(e,t,o,a)=>{let i=n("fieldset"),r=n("div","api-tokens-choices");for(let[e,i,s,p]of a){let a=n("label","api-tokens-choice",i),d=n("input");d.type=t,d.name=o,d.value=e,d.checked=s,d.dataset.focusKey=`api-tokens-${o}-${e}`,p&&a.append(n("small","",p)),a.prepend(d),r.append(a)}return i.append(n("legend","",e),r),i},k=u("Access","checkbox","scope",t.scopes.map(e=>[e,s[e]?`${s[e]} comments`:e,"comments:read"===e])),f=t.projects.includes(p),m=u("Projects","radio","projects",t.policy?.explicitProjects?t.projects.map(e=>[e,e===p?"This project":e,e===(f?p:t.projects[0])]):[...f?[["this","This project",!0]]:[],["all","All your projects",!f]]),h=u("Expires","radio","expiry",r.filter(([,e])=>!t.policy||(e?e<=t.policy.maxLifetimeDays:t.policy.noExpiry)).map(([e,t])=>[String(t),e,30===t])),x=n("p","api-tokens-error");x.setAttribute("role","alert");let y=n("div","api-tokens-actions"),b=a("Cancel",F,"secondary");b.dataset.focusKey="api-tokens-cancel";let v=a("Create token",()=>{},"primary");return v.type="submit",v.dataset.focusKey="api-tokens-create",y.append(b,v),o.append(d,l,k,m,h,x,y),o.addEventListener("submit",async n=>{if(n.preventDefault(),$)return;let a=[...o.querySelectorAll("input[name=scope]:checked")].map(e=>e.value),r=o.querySelector("input[name=expiry]:checked")?.value,s=c.value.trim()?a.length?null:k.querySelector("input"):c;if(x.textContent=c.value.trim()?a.length?"":"Choose read, write, or both.":"Name your token.",s)s.focus();else{$=!0,v.disabled=b.disabled=!0,v.setAttribute("aria-busy","true");try{let e=await i.request("account/tokens","POST",{name:c.value.trim(),scopes:a,expiresInDays:r&&"null"!==r?Number(r):null,projects:t.policy?.explicitProjects?[o.querySelector("input[name=projects]:checked")?.value].filter(e=>!!e):"this"===o.querySelector("input[name=projects]:checked")?.value?[p]:[]});if(A!==t)return;t.tokens.unshift(e.item),T=!1,E=e,U(),N("Token created. Copy it now. You won’t see it again."),K("api-tokens-copy")}catch(t){x.textContent=t instanceof e&&429===t.status?"You’ve created several tokens recently. Try again later.":L(t),v.focus()}finally{$=!1,v.disabled=b.disabled=!1,v.removeAttribute("aria-busy")}}}),o}(A)):E&&d.push(function(e){let t=n("section","api-tokens-sheet");t.setAttribute("aria-labelledby",`${g.id}-secret`);let i=n("h3","",`Copy “${e.item.name}”`);i.id=`${g.id}-secret`;let r=n("p","api-tokens-warning");r.append(o("info"),n("span","","You won’t see this token again. Store it in a secret manager, never in source control."));let s=n("div","api-tokens-secret"),p=n("code","",e.token);p.setAttribute("aria-label","New API token"),p.tabIndex=0,p.dataset.focusKey="api-tokens-secret";let d=a("Copy token",async()=>{try{await navigator.clipboard.writeText(e.token),d.replaceChildren(o("check"),document.createTextNode("Copied")),N("Token copied to the clipboard.")}catch{getSelection()?.selectAllChildren(p),N("Couldn’t copy. The token is selected; copy it with your keyboard.")}},"primary");d.replaceChildren(o("copy"),document.createTextNode("Copy")),d.removeAttribute("title"),d.dataset.focusKey="api-tokens-copy",s.append(p,d);let l=n("div","api-tokens-actions"),c=a("Done",()=>{E=null,U(),K("api-tokens-new")},"secondary");return c.dataset.focusKey="api-tokens-done",l.append(c),t.append(i,r,s,l),t}(E));if(t!==Y&&d[0]&&I(d[0]),Y=t,b.replaceChildren(...d),v.setAttribute("aria-busy",String(!A&&!C)),!A){if(C){let t=n("p","api-tokens-error",L(C));t.setAttribute("role","alert");let o=C instanceof e&&[403,404].includes(C.status),i=a("Try again",()=>{O()},"secondary");i.dataset.focusKey="api-tokens-retry",v.replaceChildren(t,...o?[]:[i])}else{let e=n("div","api-tokens-list");e.setAttribute("aria-hidden","true"),e.append(n("div","api-tokens-skeleton"),n("div","api-tokens-skeleton"));let t=n("span","sr-only","Loading API tokens");t.setAttribute("role","status"),v.replaceChildren(e,t)}return}if(!A.tokens.length){let e=n("p","api-tokens-empty");return e.append(n("strong","","No tokens yet"),n("span","","Create one for a bot, a script, or a CI job.")),void v.replaceChildren(e)}let l=n("ul","api-tokens-list");l.setAttribute("aria-label","Your API tokens"),l.append(...A.tokens.map(H));let c=n("p","api-tokens-note");c.append(document.createTextNode("Use a token as "),n("code","","PALETTE_TOKEN"),document.createTextNode(" with the palette CLI.")),v.replaceChildren(l,c)}async function O(){C=null,A=null,U();try{let t=await i.request("account/tokens");if(!Array.isArray(t.tokens)||!Array.isArray(t.projects))throw new e(0,"Couldn’t read your tokens. Try again.");A={...t,scopes:Array.isArray(t.scopes)?t.scopes:["comments:read","comments:write"]}}catch(e){C=e instanceof Error?e:new Error(String(e))}U()}return O(),k}export{u as accountTokens,d as relativeTime};
@@ -1 +1 @@
1
- function e(e,t){let o=n("details","comment-menu"),i=n("summary","icon");i.setAttribute("aria-label",e),i.setAttribute("aria-haspopup","menu"),i.setAttribute("aria-expanded","false"),i.title=e,i.append(r("more"));let l=n("div","comment-menu-items");l.popover="manual",l.setAttribute("role","menu"),l.setAttribute("aria-label",e);let s=t.map(e=>{let t=a(e.label,t=>{e.toggle&&(t.shiftKey||t.metaKey||t.ctrlKey||e.toggle.active())?e.toggle.run():(o.open=!1,i.focus({preventScroll:!0}),e.onSelect())},"menu-action"+(e.destructive?" destructive":""),e.icon);return t.append(n("span","",e.label)),t.setAttribute("role",e.toggle?"menuitemcheckbox":"menuitem"),e.toggle&&t.setAttribute("aria-checked",String(e.toggle.pressed())),t.tabIndex=-1,l.append(t),t});return o.addEventListener("toggle",()=>{if(i.setAttribute("aria-expanded",String(o.open)),o.open){l.showPopover();let e=i.getBoundingClientRect();l.style.left=`${Math.max(8,Math.min(e.right-l.offsetWidth,innerWidth-l.offsetWidth-8))}px`,l.style.top=`${Math.max(8,Math.min(e.bottom+6,innerHeight-l.offsetHeight-8))}px`,(s.find(e=>"true"===e.getAttribute("aria-checked"))??s[0])?.focus({preventScroll:!0})}else l.hidePopover()}),o.addEventListener("keydown",e=>{if(!o.open)return;let t,n=s.indexOf(e.target);"ArrowDown"===e.key&&(t=(n+1)%s.length),"ArrowUp"===e.key&&(t=(n-1+s.length)%s.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=s.length-1),void 0!==t&&(e.preventDefault(),s[t]?.focus()),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o.open=!1,i.focus({preventScroll:!0})),"Tab"===e.key&&(o.open=!1)}),o.append(i,l),o}function t(t,a,o,i){let l=e(t,a.map(([e,t])=>({label:t,icon:"check",onSelect:()=>i(e)})));l.classList.add("selection-menu");let s=l.querySelector("summary");return s.className="selection-trigger",s.replaceChildren(n("span","selection-label",a.find(([e])=>e===o)?.[1]),r("chevron")),l.querySelectorAll("[role=menuitem]").forEach((e,t)=>{e.setAttribute("role","menuitemradio"),e.setAttribute("aria-checked",String(a[t][0]===o))}),l}import{E as n,F as r,G as a}from"./chunk-QFONAD5S.js";export{e as a,t as b};
1
+ function e(e,t){let o=n("details","comment-menu"),i=n("summary","icon");i.setAttribute("aria-label",e),i.setAttribute("aria-haspopup","menu"),i.setAttribute("aria-expanded","false"),i.title=e,i.append(r("more"));let l=n("div","comment-menu-items");l.popover="manual",l.setAttribute("role","menu"),l.setAttribute("aria-label",e);let s=t.map(e=>{let t=a(e.label,t=>{e.toggle&&(t.shiftKey||t.metaKey||t.ctrlKey||e.toggle.active())?e.toggle.run():(o.open=!1,i.focus({preventScroll:!0}),e.onSelect())},"menu-action"+(e.destructive?" destructive":""),e.icon);return t.append(n("span","",e.label)),t.setAttribute("role",e.toggle?"menuitemcheckbox":"menuitem"),e.toggle&&t.setAttribute("aria-checked",String(e.toggle.pressed())),t.tabIndex=-1,l.append(t),t});return o.addEventListener("toggle",()=>{if(i.setAttribute("aria-expanded",String(o.open)),o.open){l.showPopover();let e=i.getBoundingClientRect();l.style.left=`${Math.max(8,Math.min(e.right-l.offsetWidth,innerWidth-l.offsetWidth-8))}px`,l.style.top=`${Math.max(8,Math.min(e.bottom+6,innerHeight-l.offsetHeight-8))}px`,(s.find(e=>"true"===e.getAttribute("aria-checked"))??s[0])?.focus({preventScroll:!0})}else l.hidePopover()}),o.addEventListener("keydown",e=>{if(!o.open)return;let t,n=s.indexOf(e.target);"ArrowDown"===e.key&&(t=(n+1)%s.length),"ArrowUp"===e.key&&(t=(n-1+s.length)%s.length),"Home"===e.key&&(t=0),"End"===e.key&&(t=s.length-1),void 0!==t&&(e.preventDefault(),s[t]?.focus()),"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),o.open=!1,i.focus({preventScroll:!0})),"Tab"===e.key&&(o.open=!1)}),o.append(i,l),o}function t(t,a,o,i){let l=e(t,a.map(([e,t])=>({label:t,icon:"check",onSelect:()=>i(e)})));l.classList.add("selection-menu");let s=l.querySelector("summary");return s.className="selection-trigger",s.replaceChildren(n("span","selection-label",a.find(([e])=>e===o)?.[1]),r("chevron")),l.querySelectorAll("[role=menuitem]").forEach((e,t)=>{e.setAttribute("role","menuitemradio"),e.setAttribute("aria-checked",String(a[t][0]===o))}),l}import{j as n,k as r,l as a}from"./chunk-QALADLZS.js";export{e as a,t as b};
@@ -1 +1 @@
1
- import{E as e}from"./chunk-QFONAD5S.js";var t='.palette-source{position:relative;flex:none;display:flex}.palette-source>button{width:24px;height:24px;padding:0;border:0;border-radius:6px;background:none;color:#898680;cursor:pointer}.palette-source>button::before{content:"i";display:inline-grid;place-items:center;width:12px;height:12px;border:1.2px solid;border-radius:50%;font:italic 600 9px/1 Georgia,serif}.palette-source>button:is(:hover,[aria-expanded=true]){background:#ffffff12;color:#f1efeb}.palette-source>span{position:absolute;z-index:12;top:calc(100% + 4px);right:0;width:max-content;padding:10px;border-radius:10px;background:#191819;box-shadow:0 0 0 1px #ffffff1a,0 12px 40px #0008;color:#e9e6e1;font:11px/1.45 ui-monospace,Menlo,monospace;overflow-wrap:anywhere}.palette-source span button{margin:8px 6px 0 0;padding:4px 10px;border:0;border-radius:6px;background:#ffffff12;color:#f1efeb;font:12px system-ui,sans-serif;cursor:pointer}@media (max-width:520px){.palette-source>button{width:32px;height:32px}.palette-source span button{padding:9px 12px}}';function o(t,o,n){let r=e("span","palette-source"),a=e("button","palette-source__button"),i=e("span","",o),p=`${t} source`,d=(t,o,n)=>{let r=e("button","",t);return r.type="button",r.setAttribute("aria-label",o),r.addEventListener("click",n),i.append(r),r};a.type="button",a.title=o,a.setAttribute("aria-label",p),a.setAttribute("aria-expanded","false"),i.hidden=!0,i.setAttribute("role","dialog"),i.setAttribute("aria-label",p),i.append(e("br"));let s,l,u=d("Copy","Copy source path",()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(o)).then(()=>{u.textContent="Copied"},()=>getSelection()?.selectAllChildren(i.firstChild))}),c=/^([\w@.-][^:]*?\.\w+)(?::(\d+))?(?::\d+)?$/.exec(o);try{s=c?n?.(c[1],Number(c[2])||void 0):void 0}catch{}function f(e){if(i.hidden=!e,a.setAttribute("aria-expanded",String(e)),u.textContent="Copy",l?.abort(),!e)return;let t=8,o=innerWidth-8,n=r.parentElement;for(;n&&"visible"===getComputedStyle(n).overflowX;)n=n.parentElement;if(n){let e=n.getBoundingClientRect();t=Math.max(t,e.left+4),o=Math.min(o,e.right-4)}i.style.translate="",i.style.maxWidth=`${Math.min(280,o-t)}px`;let p=i.getBoundingClientRect();i.style.translate=Math.max(0,t-p.left)-Math.max(0,p.right-o)+"px";let{signal:d}=l=new AbortController;a.getRootNode().addEventListener("pointerdown",e=>{e.composedPath().includes(r)||f(!1)},{capture:!0,signal:d}),window.addEventListener("keydown",e=>{"Escape"!==e.key||!e.composedPath().includes(r)||(e.preventDefault(),e.stopImmediatePropagation(),f(!1),a.focus())},{capture:!0,signal:d})}return s&&/^(https?|vscode|cursor):/.test(s)&&d("Open","Open source",()=>{window.open(s,"_blank","noopener,noreferrer"),f(!1)}),a.addEventListener("click",()=>f(!0===i.hidden)),r.addEventListener("focusout",e=>{e.relatedTarget instanceof Node&&!r.contains(e.relatedTarget)&&f(!1)}),r.append(a,i),r}export{t as a,o as b};
1
+ import{j as e}from"./chunk-QALADLZS.js";var t='.palette-source{position:relative;flex:none;display:flex}.palette-source>button{width:24px;height:24px;padding:0;border:0;border-radius:6px;background:none;color:#898680;cursor:pointer}.palette-source>button::before{content:"i";display:inline-grid;place-items:center;width:12px;height:12px;border:1.2px solid;border-radius:50%;font:italic 600 9px/1 Georgia,serif}.palette-source>button:is(:hover,[aria-expanded=true]){background:#ffffff12;color:#f1efeb}.palette-source>span{position:absolute;z-index:12;top:calc(100% + 4px);right:0;width:max-content;padding:10px;border-radius:10px;background:#191819;box-shadow:0 0 0 1px #ffffff1a,0 12px 40px #0008;color:#e9e6e1;font:11px/1.45 ui-monospace,Menlo,monospace;overflow-wrap:anywhere}.palette-source span button{margin:8px 6px 0 0;padding:4px 10px;border:0;border-radius:6px;background:#ffffff12;color:#f1efeb;font:12px system-ui,sans-serif;cursor:pointer}@media (max-width:520px){.palette-source>button{width:32px;height:32px}.palette-source span button{padding:9px 12px}}';function o(t,o,n){let r=e("span","palette-source"),a=e("button","palette-source__button"),i=e("span","",o),p=`${t} source`,d=(t,o,n)=>{let r=e("button","",t);return r.type="button",r.setAttribute("aria-label",o),r.addEventListener("click",n),i.append(r),r};a.type="button",a.title=o,a.setAttribute("aria-label",p),a.setAttribute("aria-expanded","false"),i.hidden=!0,i.setAttribute("role","dialog"),i.setAttribute("aria-label",p),i.append(e("br"));let s,l,u=d("Copy","Copy source path",()=>{Promise.resolve().then(()=>navigator.clipboard.writeText(o)).then(()=>{u.textContent="Copied"},()=>getSelection()?.selectAllChildren(i.firstChild))}),c=/^([\w@.-][^:]*?\.\w+)(?::(\d+))?(?::\d+)?$/.exec(o);try{s=c?n?.(c[1],Number(c[2])||void 0):void 0}catch{}function f(e){if(i.hidden=!e,a.setAttribute("aria-expanded",String(e)),u.textContent="Copy",l?.abort(),!e)return;let t=8,o=innerWidth-8,n=r.parentElement;for(;n&&"visible"===getComputedStyle(n).overflowX;)n=n.parentElement;if(n){let e=n.getBoundingClientRect();t=Math.max(t,e.left+4),o=Math.min(o,e.right-4)}i.style.translate="",i.style.maxWidth=`${Math.min(280,o-t)}px`;let p=i.getBoundingClientRect();i.style.translate=Math.max(0,t-p.left)-Math.max(0,p.right-o)+"px";let{signal:d}=l=new AbortController;a.getRootNode().addEventListener("pointerdown",e=>{e.composedPath().includes(r)||f(!1)},{capture:!0,signal:d}),window.addEventListener("keydown",e=>{"Escape"!==e.key||!e.composedPath().includes(r)||(e.preventDefault(),e.stopImmediatePropagation(),f(!1),a.focus())},{capture:!0,signal:d})}return s&&/^(https?|vscode|cursor):/.test(s)&&d("Open","Open source",()=>{window.open(s,"_blank","noopener,noreferrer"),f(!1)}),a.addEventListener("click",()=>f(!0===i.hidden)),r.addEventListener("focusout",e=>{e.relatedTarget instanceof Node&&!r.contains(e.relatedTarget)&&f(!1)}),r.append(a,i),r}export{t as a,o as b};