claudebuttons
Advanced tools
@@ -1,2 +0,2 @@ | ||
| "use strict";var ClaudeButtons=(()=>{var D=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var X=(o,n)=>{for(var t in n)D(o,t,{get:n[t],enumerable:!0})},Q=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of J(n))!Z.call(o,a)&&a!==t&&D(o,a,{get:()=>n[a],enumerable:!(e=G(n,a))||e.enumerable});return o};var tt=o=>Q(D({},"__esModule",{value:!0}),o);var ct={};X(ct,{ALT_BRAND_COLOR:()=>V,BRAND_COLOR:()=>i,BRAND_COLOR_ON_DARK:()=>C,CLAUDE_CODE_ICON:()=>v,COWORK_ICON:()=>x,ClaudeCodeButton:()=>A,ClaudePopupDialog:()=>F,CoworkButton:()=>E,createClaudeCodeButton:()=>K,createCoworkButton:()=>W,discoverButtons:()=>N,generateStructuredData:()=>I,injectStructuredData:()=>Y,isDesktopAppLinkSupported:()=>L,isMobileOrTabletDevice:()=>H,isRestrictedEmbeddedBrowser:()=>P,register:()=>st,registerClaudeCodeButton:()=>O,registerCoworkButton:()=>T,resolveTheme:()=>l,showPopup:()=>w,themes:()=>k});function P(){if(typeof navigator>"u")return!0;let o=navigator.userAgent||"";return!!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function H(){if(typeof navigator>"u")return!1;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return!!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function et(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function L(){return!(!et()||P())}var M="agentpreferences";function q(){return typeof document<"u"}function ot(){if(!q())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${M}=`));if(!o)return null;let n=o.slice(M.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return!e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function at(o){if(!q())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${M}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`}function f(o){if(!o||typeof o!="string")return;let t=ot()?.order.filter(e=>e!==o)??[];at({order:[o,...t]})}var v=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| "use strict";var ClaudeButtons=(()=>{var D=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var tt=(o,n)=>{for(var t in n)D(o,t,{get:n[t],enumerable:!0})},et=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of X(n))!Q.call(o,a)&&a!==t&&D(o,a,{get:()=>n[a],enumerable:!(e=Z(n,a))||e.enumerable});return o};var ot=o=>et(D({},"__esModule",{value:!0}),o);var pt={};tt(pt,{ALT_BRAND_COLOR:()=>V,BRAND_COLOR:()=>i,BRAND_COLOR_ON_DARK:()=>C,CLAUDE_CODE_ICON:()=>v,COWORK_ICON:()=>x,ClaudeCodeButton:()=>A,ClaudePopupDialog:()=>O,CoworkButton:()=>E,createClaudeCodeButton:()=>K,createCoworkButton:()=>W,discoverButtons:()=>N,generateStructuredData:()=>I,injectStructuredData:()=>Y,isDesktopAppLinkSupported:()=>L,isMobileOrTabletDevice:()=>H,isRestrictedEmbeddedBrowser:()=>P,register:()=>lt,registerClaudeCodeButton:()=>F,registerCoworkButton:()=>T,resolveTheme:()=>l,showPopup:()=>w,themes:()=>k});function P(){if(typeof navigator>"u")return!0;let o=navigator.userAgent||"";return!!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function H(){if(typeof navigator>"u")return!1;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return!!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function at(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function L(){return!(!at()||P())}var M="agentpreferences";function q(){return typeof document<"u"}function rt(){if(!q())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${M}=`));if(!o)return null;let n=o.slice(M.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return!e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function nt(o){if(!q())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${M}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`}function f(o){if(!o||typeof o!="string")return;let t=rt()?.order.filter(e=>e!==o)??[];nt({order:[o,...t]})}var v=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| <!-- Ears --> | ||
@@ -50,3 +50,3 @@ <rect x="3.5" y="1.5" width="5" height="5" rx="1.5" fill="currentColor"/> | ||
| --cb-code-text: ${o.codeText}; | ||
| `}var V="#6B5CE7",$={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},S={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var rt=` | ||
| `}var V="#6B5CE7",$={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},S={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var it=` | ||
| :host { | ||
@@ -410,4 +410,4 @@ position: fixed; | ||
| } | ||
| `,F=class extends HTMLElement{constructor(){super();this._mqCleanup=null;this._autoLaunchConsumed=!1;this.attachShadow({mode:"open"})}set options(t){this._autoLaunchConsumed=!1,this._options=t,this.render()}get options(){return this._options}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null}resolvePopupTokens(){let{theme:t}=this._options;if(t==="dark"||t==="light")return l(t);let e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(t==="system")return e?l("dark"):l("light");let a=e?l("dark"):l("light"),r=l(t);return{...a,primary:r.primary,primaryText:r.primaryText}}render(){if(!this.shadowRoot||!this._options)return;let{variant:t,title:e,description:a,command:r,fullCommand:s,desktopLaunchUrl:d,autoLaunch:c}=this._options,p=this.resolvePopupTokens(),b=t==="claude-code"?v:x,g=t==="claude-code",_=s||r,u=d??"claude://",h=L();this.shadowRoot.innerHTML=` | ||
| <style>${rt}</style> | ||
| `,O=class extends HTMLElement{constructor(){super();this._mqCleanup=null;this._autoLaunchConsumed=!1;this.attachShadow({mode:"open"})}set options(t){this._autoLaunchConsumed=!1,this._options=t,this.render()}get options(){return this._options}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null}resolvePopupTokens(){let{theme:t}=this._options;if(t==="dark"||t==="light")return l(t);let e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(t==="system")return e?l("dark"):l("light");let a=e?l("dark"):l("light"),r=l(t);return{...a,primary:r.primary,primaryText:r.primaryText}}render(){if(!this.shadowRoot||!this._options)return;let{variant:t,title:e,description:a,command:r,fullCommand:s,desktopLaunchUrl:d,autoLaunch:c}=this._options,p=this.resolvePopupTokens(),b=t==="claude-code"?v:x,g=t==="claude-code",_=s||r,u=d??"claude://",h=L();this.shadowRoot.innerHTML=` | ||
| <style>${it}</style> | ||
| <div style="${y(p)}"> | ||
@@ -492,3 +492,3 @@ <div class="cb-backdrop" data-action="close"></div> | ||
| <div class="cb-hint">Press <kbd>\u2318</kbd>+<kbd>V</kbd> or <kbd>Ctrl</kbd>+<kbd>V</kbd> in your terminal to run</div> | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e)}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href)}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close()}))}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r)}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,s=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${j}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${B}<span>Copy</span>`},2e3)}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t)}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove()},140)}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",F);function w(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var nt=` | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e)}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href)}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close()}))}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r)}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,s=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${j}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${B}<span>Copy</span>`},2e3)}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t)}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove()},140)}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",O);function w(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var st=` | ||
| :host { | ||
@@ -731,3 +731,3 @@ display: inline-block; | ||
| `,A=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:!0,promptFlag:!0};this._mqCleanup=null;this._rendered=!1;this.attachShadow({mode:"open"})}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM()}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM())}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM()}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),s=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("prompt-flag"),p=this.getAttribute("popup-title"),b=this.getAttribute("popup-description");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),s&&(this._options.shape=s),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.promptFlag=c!=="false"),p!==null&&(this._options.popupTitle=p),b!==null&&(this._options.popupDescription=b)}updateLightDOM(){let{command:t}=this._options,e=this.getFullCommand();this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Claude Code: ${t}`),this._options.popup!==!1?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let a=this.querySelector("a[data-cb-crawl]");a||(a=document.createElement("a"),a.setAttribute("data-cb-crawl",""),a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(a)),a.href=`https://claude.ai/code?command=${encodeURIComponent(e)}`,a.textContent=`Run on Claude Code: ${t}`,a.setAttribute("data-platform","claude-code"),a.setAttribute("data-command",t),a.setAttribute("data-full-command",e)}getResolvedTheme(){return this._options.theme||"branded"}getFullCommand(){let{command:t,promptFlag:e}=this._options;return e===!1?t:`claude -p "${t}"`}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),s=this._options.size||"md",d=this._options.shape||"rounded",c=S[s],p=$[d][s];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,_=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${nt}</style> | ||
| <style>${st}</style> | ||
| <button | ||
@@ -755,3 +755,3 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick())}),this._rendered=!0,this.setupSystemThemeWatch()}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,s=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:!0,composed:!0,detail:{command:e,fullCommand:s}})),t===!1){navigator.clipboard.writeText(s).then(()=>{this._options.onCopy?.(s),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:s}}))});return}w({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:s,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:d}}))},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:!0,composed:!0}))}})}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e)}};A.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function O(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,A)}O();function K(o){let n=document.createElement("claude-code-button");return n.options=o,n}var it=` | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick())}),this._rendered=!0,this.setupSystemThemeWatch()}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,s=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:!0,composed:!0,detail:{command:e,fullCommand:s}})),t===!1){navigator.clipboard.writeText(s).then(()=>{this._options.onCopy?.(s),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:s}}))});return}w({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:s,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:d}}))},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:!0,composed:!0}))}})}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e)}};A.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function F(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,A)}F();function K(o){let n=document.createElement("claude-code-button");return n.options=o,n}var ct=` | ||
| :host { | ||
@@ -996,3 +996,3 @@ display: inline-block; | ||
| `,E=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:!0};this._mqCleanup=null;this._rendered=!1;this.attachShadow({mode:"open"})}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM()}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM())}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM()}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),s=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("popup-title"),p=this.getAttribute("popup-description"),b=this.getAttribute("auto-launch");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),s&&(this._options.shape=s),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.popupTitle=c),p!==null&&(this._options.popupDescription=p),b===null?delete this._options.autoLaunch:this._options.autoLaunch=b!=="false"}updateLightDOM(){let{command:t}=this._options;this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Cowork: ${t}`),this._options.popup!==!1?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let e=this.querySelector("a[data-cb-crawl]");e||(e=document.createElement("a"),e.setAttribute("data-cb-crawl",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(e)),e.textContent=`Run on Cowork: ${t}`,e.setAttribute("data-platform","cowork"),e.setAttribute("data-command",t),e.href=`https://claude.ai/cowork?command=${encodeURIComponent(t)}`}getResolvedTheme(){return this._options.theme||"branded"}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),s=this._options.size||"md",d=this._options.shape||"rounded",c=S[s],p=$[d][s];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,_=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${it}</style> | ||
| <style>${ct}</style> | ||
| <button | ||
@@ -1020,3 +1020,3 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick())}),this._rendered=!0,this.setupSystemThemeWatch()}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:s}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:!0,composed:!0,detail:{command:e}})),t===!1){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:e}}))});return}w({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:s===!0,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:d}}))},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:!0,composed:!0}))}})}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e)}};E.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function T(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E)}T();function W(o){let n=document.createElement("cowork-button");return n.options=o,n}function N(){if(typeof document>"u")return[];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r})}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t})}),o}function I(){let o=N();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return{"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return{"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function Y(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=I();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t)}function st(){O(),T()}return tt(ct);})(); | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick())}),this._rendered=!0,this.setupSystemThemeWatch()}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:s}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:!0,composed:!0,detail:{command:e}})),t===!1){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:e}}))});return}w({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:s===!0,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:!0,composed:!0,detail:{command:d}}))},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:!0,composed:!0}))}})}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e)}};E.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function T(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E)}T();function W(o){let n=document.createElement("cowork-button");return n.options=o,n}function N(){if(typeof document>"u")return[];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r})}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t})}),o}function I(){let o=N();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return{"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return{"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function Y(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=I();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t)}var G="https://claudebuttons.vercel.app/api/ping",J=!1;function dt(){if(J||typeof window>"u"||typeof navigator>"u")return;let o=window.location?.origin;if(!(!o||o==="null"||o.startsWith("file:"))){J=!0;try{let n=JSON.stringify({origin:o}),t=new Blob([n],{type:"text/plain"});typeof navigator.sendBeacon=="function"?navigator.sendBeacon(G,t):fetch(G,{method:"POST",body:n,keepalive:!0}).catch(()=>{})}catch{}}}if(typeof window<"u")try{dt()}catch{}function lt(){F(),T()}return ot(pt);})(); | ||
| //# sourceMappingURL=index.global.js.map |
+15
-15
@@ -1,2 +0,2 @@ | ||
| 'use strict';function M(){if(typeof navigator>"u")return true;let o=navigator.userAgent||"";return !!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function j(){if(typeof navigator>"u")return false;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return !!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function U(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function S(){return !(!U()||M())}var D="agentpreferences";function z(){return typeof document<"u"}function V(){if(!z())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${D}=`));if(!o)return null;let n=o.slice(D.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return !e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function K(o){if(!z())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${D}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`;}function f(o){if(!o||typeof o!="string")return;let t=V()?.order.filter(e=>e!==o)??[];K({order:[o,...t]});}var k=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| 'use strict';function M(){if(typeof navigator>"u")return true;let o=navigator.userAgent||"";return !!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function V(){if(typeof navigator>"u")return false;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return !!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function K(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function S(){return !(!K()||M())}var D="agentpreferences";function z(){return typeof document<"u"}function W(){if(!z())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${D}=`));if(!o)return null;let n=o.slice(D.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return !e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function Y(o){if(!z())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${D}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`;}function f(o){if(!o||typeof o!="string")return;let t=W()?.order.filter(e=>e!==o)??[];Y({order:[o,...t]});}var k=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| <!-- Ears --> | ||
@@ -25,3 +25,3 @@ <rect x="3.5" y="1.5" width="5" height="5" rx="1.5" fill="currentColor"/> | ||
| <circle cx="12.4" cy="15.5" r="1.3" fill="var(--cb-icon-accent, white)"/> | ||
| </svg>`,F=`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon-sm"> | ||
| </svg>`,O=`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon-sm"> | ||
| <rect x="5" y="5" width="8" height="8" rx="1.5" stroke="currentColor" stroke-width="1.5" fill="none"/> | ||
@@ -40,3 +40,3 @@ <path d="M3 10V3.5A1.5 1.5 0 014.5 2H10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/> | ||
| <path d="M8 16.5h8v3H8v-3z" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linejoin="round"/> | ||
| </svg>`;var s="#D4795C",m="#C06A4E",O="#B35E43",w="#F0B8A8",y={branded:{bg:s,text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},"branded-alt":{bg:"#6B5CE7",text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:"#6B5CE7",primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},dark:{bg:"#1C1917",text:"#F5F0EB",border:"#3D3530",surface:"#292524",surfaceText:"#F5F0EB",muted:"#A8A29E",primary:s,primaryText:"#FFFFFF",codeBg:"#0C0A09",codeText:"#F5F0EB"},light:{bg:"#FFFFFF",text:"#1C1917",border:"#E7E5E4",surface:"#FAFAF9",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"}};function l(o){return o!=="system"?y[o]:typeof window>"u"?y.light:window.matchMedia("(prefers-color-scheme: dark)").matches?y.dark:y.light}function v(o){return ` | ||
| </svg>`;var s="#D4795C",m="#C06A4E",F="#B35E43",w="#F0B8A8",y={branded:{bg:s,text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},"branded-alt":{bg:"#6B5CE7",text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:"#6B5CE7",primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},dark:{bg:"#1C1917",text:"#F5F0EB",border:"#3D3530",surface:"#292524",surfaceText:"#F5F0EB",muted:"#A8A29E",primary:s,primaryText:"#FFFFFF",codeBg:"#0C0A09",codeText:"#F5F0EB"},light:{bg:"#FFFFFF",text:"#1C1917",border:"#E7E5E4",surface:"#FAFAF9",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"}};function l(o){return o!=="system"?y[o]:typeof window>"u"?y.light:window.matchMedia("(prefers-color-scheme: dark)").matches?y.dark:y.light}function v(o){return ` | ||
| --cb-bg: ${o.bg}; | ||
@@ -52,3 +52,3 @@ --cb-text: ${o.text}; | ||
| --cb-code-text: ${o.codeText}; | ||
| `}var W="#6B5CE7",T={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},L={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var Y=` | ||
| `}var G="#6B5CE7",T={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},L={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var J=` | ||
| :host { | ||
@@ -413,3 +413,3 @@ position: fixed; | ||
| `,B=class extends HTMLElement{constructor(){super();this._mqCleanup=null;this._autoLaunchConsumed=false;this.attachShadow({mode:"open"});}set options(t){this._autoLaunchConsumed=false,this._options=t,this.render();}get options(){return this._options}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}resolvePopupTokens(){let{theme:t}=this._options;if(t==="dark"||t==="light")return l(t);let e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(t==="system")return e?l("dark"):l("light");let a=e?l("dark"):l("light"),r=l(t);return {...a,primary:r.primary,primaryText:r.primaryText}}render(){if(!this.shadowRoot||!this._options)return;let{variant:t,title:e,description:a,command:r,fullCommand:i,desktopLaunchUrl:d,autoLaunch:c}=this._options,p=this.resolvePopupTokens(),b=t==="claude-code"?k:C,g=t==="claude-code",x=i||r,u=d??"claude://",h=S();this.shadowRoot.innerHTML=` | ||
| <style>${Y}</style> | ||
| <style>${J}</style> | ||
| <div style="${v(p)}"> | ||
@@ -441,3 +441,3 @@ <div class="cb-backdrop" data-action="close"></div> | ||
| <div class="cb-code-text"><span class="cb-code-prefix">$</span>${this.escapeHtml(t)}</div> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${F}<span>Copy</span></button> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${O}<span>Copy</span></button> | ||
| </div> | ||
@@ -459,3 +459,3 @@ </div> | ||
| <div class="cb-code-text">${this.escapeHtml(t)}</div> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${F}<span>Copy</span></button> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${O}<span>Copy</span></button> | ||
| </div> | ||
@@ -496,3 +496,3 @@ </div> | ||
| <div class="cb-hint">Press <kbd>\u2318</kbd>+<kbd>V</kbd> or <kbd>Ctrl</kbd>+<kbd>V</kbd> in your terminal to run</div> | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e);}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href);}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close();}));}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r);}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,i=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${N}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${F}<span>Copy</span>`;},2e3);}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t);}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove();},140);}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",B);function A(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var G=` | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e);}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href);}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close();}));}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r);}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,i=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${N}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${O}<span>Copy</span>`;},2e3);}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t);}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove();},140);}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",B);function A(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var Z=` | ||
| :host { | ||
@@ -546,3 +546,3 @@ display: inline-block; | ||
| :host([data-variant="filled"][data-theme="branded"]) .cb-btn:active { | ||
| background: ${O}; | ||
| background: ${F}; | ||
| transform: scale(0.98); | ||
@@ -736,3 +736,3 @@ } | ||
| `,E=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:true,promptFlag:true};this._mqCleanup=null;this._rendered=false;this.attachShadow({mode:"open"});}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM();}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM());}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM();}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),i=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("prompt-flag"),p=this.getAttribute("popup-title"),b=this.getAttribute("popup-description");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),i&&(this._options.shape=i),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.promptFlag=c!=="false"),p!==null&&(this._options.popupTitle=p),b!==null&&(this._options.popupDescription=b);}updateLightDOM(){let{command:t}=this._options,e=this.getFullCommand();this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Claude Code: ${t}`),this._options.popup!==false?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let a=this.querySelector("a[data-cb-crawl]");a||(a=document.createElement("a"),a.setAttribute("data-cb-crawl",""),a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(a)),a.href=`https://claude.ai/code?command=${encodeURIComponent(e)}`,a.textContent=`Run on Claude Code: ${t}`,a.setAttribute("data-platform","claude-code"),a.setAttribute("data-command",t),a.setAttribute("data-full-command",e);}getResolvedTheme(){return this._options.theme||"branded"}getFullCommand(){let{command:t,promptFlag:e}=this._options;return e===false?t:`claude -p "${t}"`}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),i=this._options.size||"md",d=this._options.shape||"rounded",c=L[i],p=T[d][i];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,x=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${G}</style> | ||
| <style>${Z}</style> | ||
| <button | ||
@@ -760,3 +760,3 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,i=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e,fullCommand:i}})),t===false){navigator.clipboard.writeText(i).then(()=>{this._options.onCopy?.(i),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:i}}));});return}A({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:i,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};E.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function R(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E);}R();function J(o){let n=document.createElement("claude-code-button");return n.options=o,n}var Z=` | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,i=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e,fullCommand:i}})),t===false){navigator.clipboard.writeText(i).then(()=>{this._options.onCopy?.(i),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:i}}));});return}A({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:i,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};E.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function R(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E);}R();function X(o){let n=document.createElement("claude-code-button");return n.options=o,n}var Q=` | ||
| :host { | ||
@@ -810,3 +810,3 @@ display: inline-block; | ||
| :host([data-variant="filled"][data-theme="branded"]) .cb-btn:active { | ||
| background: ${O}; | ||
| background: ${F}; | ||
| transform: scale(0.98); | ||
@@ -1002,3 +1002,3 @@ } | ||
| `,_=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:true};this._mqCleanup=null;this._rendered=false;this.attachShadow({mode:"open"});}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM();}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM());}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM();}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),i=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("popup-title"),p=this.getAttribute("popup-description"),b=this.getAttribute("auto-launch");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),i&&(this._options.shape=i),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.popupTitle=c),p!==null&&(this._options.popupDescription=p),b===null?delete this._options.autoLaunch:this._options.autoLaunch=b!=="false";}updateLightDOM(){let{command:t}=this._options;this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Cowork: ${t}`),this._options.popup!==false?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let e=this.querySelector("a[data-cb-crawl]");e||(e=document.createElement("a"),e.setAttribute("data-cb-crawl",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(e)),e.textContent=`Run on Cowork: ${t}`,e.setAttribute("data-platform","cowork"),e.setAttribute("data-command",t),e.href=`https://claude.ai/cowork?command=${encodeURIComponent(t)}`;}getResolvedTheme(){return this._options.theme||"branded"}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),i=this._options.size||"md",d=this._options.shape||"rounded",c=L[i],p=T[d][i];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,x=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${Z}</style> | ||
| <style>${Q}</style> | ||
| <button | ||
@@ -1026,4 +1026,4 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:i}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e}})),t===false){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:e}}));});return}A({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:i===true,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};_.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function $(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,_);}$();function X(o){let n=document.createElement("cowork-button");return n.options=o,n}function H(){if(typeof document>"u")return [];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r});}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t});}),o}function q(){let o=H();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return {"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return {"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function Q(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=q();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t);}function yt(){R(),$();} | ||
| exports.ALT_BRAND_COLOR=W;exports.BRAND_COLOR=s;exports.BRAND_COLOR_ON_DARK=w;exports.CLAUDE_CODE_ICON=k;exports.COWORK_ICON=C;exports.ClaudeCodeButton=E;exports.ClaudePopupDialog=B;exports.CoworkButton=_;exports.createClaudeCodeButton=J;exports.createCoworkButton=X;exports.discoverButtons=H;exports.generateStructuredData=q;exports.injectStructuredData=Q;exports.isDesktopAppLinkSupported=S;exports.isMobileOrTabletDevice=j;exports.isRestrictedEmbeddedBrowser=M;exports.register=yt;exports.registerClaudeCodeButton=R;exports.registerCoworkButton=$;exports.resolveTheme=l;exports.showPopup=A;exports.themes=y;//# sourceMappingURL=index.js.map | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:i}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e}})),t===false){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:e}}));});return}A({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:i===true,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};_.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function $(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,_);}$();function tt(o){let n=document.createElement("cowork-button");return n.options=o,n}function H(){if(typeof document>"u")return [];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r});}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t});}),o}function q(){let o=H();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return {"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return {"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function et(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=q();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t);}var j="https://claudebuttons.vercel.app/api/ping",U=false;function ot(){if(U||typeof window>"u"||typeof navigator>"u")return;let o=window.location?.origin;if(!(!o||o==="null"||o.startsWith("file:"))){U=true;try{let n=JSON.stringify({origin:o}),t=new Blob([n],{type:"text/plain"});typeof navigator.sendBeacon=="function"?navigator.sendBeacon(j,t):fetch(j,{method:"POST",body:n,keepalive:!0}).catch(()=>{});}catch{}}}if(typeof window<"u")try{ot();}catch{}function _t(){R(),$();} | ||
| exports.ALT_BRAND_COLOR=G;exports.BRAND_COLOR=s;exports.BRAND_COLOR_ON_DARK=w;exports.CLAUDE_CODE_ICON=k;exports.COWORK_ICON=C;exports.ClaudeCodeButton=E;exports.ClaudePopupDialog=B;exports.CoworkButton=_;exports.createClaudeCodeButton=X;exports.createCoworkButton=tt;exports.discoverButtons=H;exports.generateStructuredData=q;exports.injectStructuredData=et;exports.isDesktopAppLinkSupported=S;exports.isMobileOrTabletDevice=V;exports.isRestrictedEmbeddedBrowser=M;exports.register=_t;exports.registerClaudeCodeButton=R;exports.registerCoworkButton=$;exports.resolveTheme=l;exports.showPopup=A;exports.themes=y;//# sourceMappingURL=index.js.map | ||
| //# sourceMappingURL=index.js.map |
+15
-15
@@ -1,2 +0,2 @@ | ||
| function M(){if(typeof navigator>"u")return true;let o=navigator.userAgent||"";return !!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function j(){if(typeof navigator>"u")return false;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return !!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function U(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function S(){return !(!U()||M())}var D="agentpreferences";function z(){return typeof document<"u"}function V(){if(!z())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${D}=`));if(!o)return null;let n=o.slice(D.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return !e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function K(o){if(!z())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${D}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`;}function f(o){if(!o||typeof o!="string")return;let t=V()?.order.filter(e=>e!==o)??[];K({order:[o,...t]});}var k=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| function M(){if(typeof navigator>"u")return true;let o=navigator.userAgent||"";return !!(!o.trim()||/\bFBAN\b|\bFBAV\b|FB_IAB|Instagram|Line\/|MicroMessenger|Snapchat|TikTok|LinkedInApp|Pinterest/i.test(o)||/Twitter for (iPhone|Android)/i.test(o)||/; wv\)/.test(o)||/Opera Mini|OPiOS/i.test(o))}function V(){if(typeof navigator>"u")return false;let o=navigator.userAgent||"",n=typeof navigator.maxTouchPoints=="number"?navigator.maxTouchPoints:0,t=navigator.platform||"";return !!(/iPhone|iPod/i.test(o)||/iPad/i.test(o)||/Android/i.test(o)&&/Mobile/i.test(o)||/Android/i.test(o)&&!/Mobile/i.test(o)||(t==="MacIntel"||t==="MacARM")&&n>1||/webOS|BlackBerry|IEMobile|Opera Mini/i.test(o))}function K(){return typeof window<"u"&&typeof document<"u"&&typeof document.createElement=="function"}function S(){return !(!K()||M())}var D="agentpreferences";function z(){return typeof document<"u"}function W(){if(!z())return null;let o=document.cookie.split(";").map(t=>t.trim()).find(t=>t.startsWith(`${D}=`));if(!o)return null;let n=o.slice(D.length+1);if(!n)return null;try{let t=decodeURIComponent(n),e=JSON.parse(t);return !e||typeof e!="object"||!Array.isArray(e.order)?null:{order:e.order.filter(r=>typeof r=="string"&&r.length>0)}}catch{return null}}function Y(o){if(!z())return;let n=o.order.slice(0,24),t=JSON.stringify({order:n}),e=new Date;e.setFullYear(e.getFullYear()+1),document.cookie=`${D}=${encodeURIComponent(t)}; Path=/; SameSite=Lax; Expires=${e.toUTCString()}`;}function f(o){if(!o||typeof o!="string")return;let t=W()?.order.filter(e=>e!==o)??[];Y({order:[o,...t]});}var k=`<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon"> | ||
| <!-- Ears --> | ||
@@ -25,3 +25,3 @@ <rect x="3.5" y="1.5" width="5" height="5" rx="1.5" fill="currentColor"/> | ||
| <circle cx="12.4" cy="15.5" r="1.3" fill="var(--cb-icon-accent, white)"/> | ||
| </svg>`,F=`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon-sm"> | ||
| </svg>`,O=`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" class="cb-icon-sm"> | ||
| <rect x="5" y="5" width="8" height="8" rx="1.5" stroke="currentColor" stroke-width="1.5" fill="none"/> | ||
@@ -40,3 +40,3 @@ <path d="M3 10V3.5A1.5 1.5 0 014.5 2H10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/> | ||
| <path d="M8 16.5h8v3H8v-3z" stroke="currentColor" stroke-width="1.5" fill="none" stroke-linejoin="round"/> | ||
| </svg>`;var s="#D4795C",m="#C06A4E",O="#B35E43",w="#F0B8A8",y={branded:{bg:s,text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},"branded-alt":{bg:"#6B5CE7",text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:"#6B5CE7",primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},dark:{bg:"#1C1917",text:"#F5F0EB",border:"#3D3530",surface:"#292524",surfaceText:"#F5F0EB",muted:"#A8A29E",primary:s,primaryText:"#FFFFFF",codeBg:"#0C0A09",codeText:"#F5F0EB"},light:{bg:"#FFFFFF",text:"#1C1917",border:"#E7E5E4",surface:"#FAFAF9",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"}};function l(o){return o!=="system"?y[o]:typeof window>"u"?y.light:window.matchMedia("(prefers-color-scheme: dark)").matches?y.dark:y.light}function v(o){return ` | ||
| </svg>`;var s="#D4795C",m="#C06A4E",F="#B35E43",w="#F0B8A8",y={branded:{bg:s,text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},"branded-alt":{bg:"#6B5CE7",text:"#FFFFFF",border:"transparent",surface:"#FFFFFF",surfaceText:"#1C1917",muted:"#78716C",primary:"#6B5CE7",primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"},dark:{bg:"#1C1917",text:"#F5F0EB",border:"#3D3530",surface:"#292524",surfaceText:"#F5F0EB",muted:"#A8A29E",primary:s,primaryText:"#FFFFFF",codeBg:"#0C0A09",codeText:"#F5F0EB"},light:{bg:"#FFFFFF",text:"#1C1917",border:"#E7E5E4",surface:"#FAFAF9",surfaceText:"#1C1917",muted:"#78716C",primary:s,primaryText:"#FFFFFF",codeBg:"#1C1917",codeText:"#F5F0EB"}};function l(o){return o!=="system"?y[o]:typeof window>"u"?y.light:window.matchMedia("(prefers-color-scheme: dark)").matches?y.dark:y.light}function v(o){return ` | ||
| --cb-bg: ${o.bg}; | ||
@@ -52,3 +52,3 @@ --cb-text: ${o.text}; | ||
| --cb-code-text: ${o.codeText}; | ||
| `}var W="#6B5CE7",T={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},L={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var Y=` | ||
| `}var G="#6B5CE7",T={rounded:{sm:"0.375rem",md:"0.5rem",lg:"0.625rem"},pill:{sm:"999px",md:"999px",lg:"999px"},square:{sm:"0",md:"0",lg:"0"}},L={sm:{height:"2rem",fontSize:"0.75rem",iconSize:"0.875rem",padding:"0 0.75rem",ccPadding:"0 0.5rem",gap:"0.375rem",radius:"0.375rem"},md:{height:"2.5rem",fontSize:"0.875rem",iconSize:"1.125rem",padding:"0 1rem",ccPadding:"0 0.75rem",gap:"0.5rem",radius:"0.5rem"},lg:{height:"3rem",fontSize:"1rem",iconSize:"1.375rem",padding:"0 1.25rem",ccPadding:"0 1rem",gap:"0.625rem",radius:"0.625rem"}};var J=` | ||
| :host { | ||
@@ -413,3 +413,3 @@ position: fixed; | ||
| `,B=class extends HTMLElement{constructor(){super();this._mqCleanup=null;this._autoLaunchConsumed=false;this.attachShadow({mode:"open"});}set options(t){this._autoLaunchConsumed=false,this._options=t,this.render();}get options(){return this._options}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}resolvePopupTokens(){let{theme:t}=this._options;if(t==="dark"||t==="light")return l(t);let e=typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches;if(t==="system")return e?l("dark"):l("light");let a=e?l("dark"):l("light"),r=l(t);return {...a,primary:r.primary,primaryText:r.primaryText}}render(){if(!this.shadowRoot||!this._options)return;let{variant:t,title:e,description:a,command:r,fullCommand:i,desktopLaunchUrl:d,autoLaunch:c}=this._options,p=this.resolvePopupTokens(),b=t==="claude-code"?k:C,g=t==="claude-code",x=i||r,u=d??"claude://",h=S();this.shadowRoot.innerHTML=` | ||
| <style>${Y}</style> | ||
| <style>${J}</style> | ||
| <div style="${v(p)}"> | ||
@@ -441,3 +441,3 @@ <div class="cb-backdrop" data-action="close"></div> | ||
| <div class="cb-code-text"><span class="cb-code-prefix">$</span>${this.escapeHtml(t)}</div> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${F}<span>Copy</span></button> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${O}<span>Copy</span></button> | ||
| </div> | ||
@@ -459,3 +459,3 @@ </div> | ||
| <div class="cb-code-text">${this.escapeHtml(t)}</div> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${F}<span>Copy</span></button> | ||
| <button class="cb-copy-btn" data-action="copy" data-command="${this.escapeAttr(t)}">${O}<span>Copy</span></button> | ||
| </div> | ||
@@ -496,3 +496,3 @@ </div> | ||
| <div class="cb-hint">Press <kbd>\u2318</kbd>+<kbd>V</kbd> or <kbd>Ctrl</kbd>+<kbd>V</kbd> in your terminal to run</div> | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e);}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href);}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close();}));}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r);}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,i=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${N}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${F}<span>Copy</span>`;},2e3);}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t);}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove();},140);}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",B);function A(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var G=` | ||
| `}escapeHref(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}setupListeners(){this.shadowRoot&&(this.shadowRoot.addEventListener("click",t=>{let e=t.target.closest("[data-action]");if(!e)return;let a=e.dataset.action;if(a==="close")this.close();else if(a==="copy"){let r=e.dataset.command||"";this.copyToClipboard(r,e);}else if(a==="launch-desktop"){t.preventDefault();let r=e.getAttribute("href")||"";this.openDesktopAppLink(r||e.href);}}),this.shadowRoot.addEventListener("keydown",t=>{t.key==="Escape"&&this.close();}));}setupSystemThemeWatch(){this._mqCleanup?.(),this._mqCleanup=null;let t=this._options.theme;if(!(t==="system"||t==="branded"||t==="branded-alt")||typeof window>"u")return;let a=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>this.render();a.addEventListener("change",r),this._mqCleanup=()=>a.removeEventListener("change",r);}async copyToClipboard(t,e){try{await navigator.clipboard.writeText(t);let a=e.querySelector("span"),r=e,i=r.querySelector(".cb-icon-sm")?.outerHTML||"";e.setAttribute("data-copied","true"),a&&(a.textContent="Copied!"),r.innerHTML=`${N}<span>Copied!</span>`,this._options.onCopy?.(t),setTimeout(()=>{e.setAttribute("data-copied","false"),r.innerHTML=`${O}<span>Copy</span>`;},2e3);}catch{let a=document.createElement("textarea");a.value=t,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),this._options.onCopy?.(t);}}close(){let t=this.shadowRoot?.querySelector(".cb-dialog"),e=this.shadowRoot?.querySelector(".cb-backdrop");t&&(t.style.animation="cb-scale-in 0.15s ease-in reverse"),e&&(e.style.animation="cb-fade-in 0.15s ease-in reverse"),setTimeout(()=>{this._options.onClose?.(),this.remove();},140);}escapeHtml(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}escapeAttr(t){return t.replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}};typeof customElements<"u"&&!customElements.get("claude-popup-dialog")&&customElements.define("claude-popup-dialog",B);function A(o){let n=document.createElement("claude-popup-dialog");return n.options=o,document.body.appendChild(n),n}var Z=` | ||
| :host { | ||
@@ -546,3 +546,3 @@ display: inline-block; | ||
| :host([data-variant="filled"][data-theme="branded"]) .cb-btn:active { | ||
| background: ${O}; | ||
| background: ${F}; | ||
| transform: scale(0.98); | ||
@@ -736,3 +736,3 @@ } | ||
| `,E=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:true,promptFlag:true};this._mqCleanup=null;this._rendered=false;this.attachShadow({mode:"open"});}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM();}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM());}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM();}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),i=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("prompt-flag"),p=this.getAttribute("popup-title"),b=this.getAttribute("popup-description");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),i&&(this._options.shape=i),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.promptFlag=c!=="false"),p!==null&&(this._options.popupTitle=p),b!==null&&(this._options.popupDescription=b);}updateLightDOM(){let{command:t}=this._options,e=this.getFullCommand();this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Claude Code: ${t}`),this._options.popup!==false?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let a=this.querySelector("a[data-cb-crawl]");a||(a=document.createElement("a"),a.setAttribute("data-cb-crawl",""),a.setAttribute("aria-hidden","true"),a.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(a)),a.href=`https://claude.ai/code?command=${encodeURIComponent(e)}`,a.textContent=`Run on Claude Code: ${t}`,a.setAttribute("data-platform","claude-code"),a.setAttribute("data-command",t),a.setAttribute("data-full-command",e);}getResolvedTheme(){return this._options.theme||"branded"}getFullCommand(){let{command:t,promptFlag:e}=this._options;return e===false?t:`claude -p "${t}"`}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),i=this._options.size||"md",d=this._options.shape||"rounded",c=L[i],p=T[d][i];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,x=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${G}</style> | ||
| <style>${Z}</style> | ||
| <button | ||
@@ -760,3 +760,3 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,i=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e,fullCommand:i}})),t===false){navigator.clipboard.writeText(i).then(()=>{this._options.onCopy?.(i),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:i}}));});return}A({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:i,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};E.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function R(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E);}R();function J(o){let n=document.createElement("claude-code-button");return n.options=o,n}var Z=` | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r}=this._options,i=this.getFullCommand();if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e,fullCommand:i}})),t===false){navigator.clipboard.writeText(i).then(()=>{this._options.onCopy?.(i),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:i}}));});return}A({variant:"claude-code",theme:this.getResolvedTheme(),title:a||"Run on Claude Code",description:r||"Execute this command in your terminal to get started.",command:e,fullCommand:i,onCopy:d=>{this._options.onCopy?.(d),f("claude-code"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};E.observedAttributes=["command","theme","size","variant","shape","popup","prompt-flag","popup-title","popup-description"];function R(o="claude-code-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,E);}R();function X(o){let n=document.createElement("claude-code-button");return n.options=o,n}var Q=` | ||
| :host { | ||
@@ -810,3 +810,3 @@ display: inline-block; | ||
| :host([data-variant="filled"][data-theme="branded"]) .cb-btn:active { | ||
| background: ${O}; | ||
| background: ${F}; | ||
| transform: scale(0.98); | ||
@@ -1002,3 +1002,3 @@ } | ||
| `,_=class extends HTMLElement{constructor(){super();this._options={command:"",theme:"branded",size:"md",variant:"filled",popup:true};this._mqCleanup=null;this._rendered=false;this.attachShadow({mode:"open"});}connectedCallback(){this.syncFromAttributes(),this.render(),this.updateLightDOM();}disconnectedCallback(){this._mqCleanup?.(),this._mqCleanup=null;}attributeChangedCallback(){this._rendered&&(this.syncFromAttributes(),this.render(),this.updateLightDOM());}set options(t){this._options={...this._options,...t},this.render(),this.updateLightDOM();}get options(){return this._options}syncFromAttributes(){let t=this.getAttribute("command"),e=this.getAttribute("theme"),a=this.getAttribute("size"),r=this.getAttribute("variant"),i=this.getAttribute("shape"),d=this.getAttribute("popup"),c=this.getAttribute("popup-title"),p=this.getAttribute("popup-description"),b=this.getAttribute("auto-launch");t!==null&&(this._options.command=t),e&&(this._options.theme=e),a&&(this._options.size=a),r&&(this._options.variant=r),i&&(this._options.shape=i),d!==null&&(this._options.popup=d!=="false"),c!==null&&(this._options.popupTitle=c),p!==null&&(this._options.popupDescription=p),b===null?delete this._options.autoLaunch:this._options.autoLaunch=b!=="false";}updateLightDOM(){let{command:t}=this._options;this.setAttribute("role","button"),this.setAttribute("tabindex","0"),this.setAttribute("aria-label",`Run on Cowork: ${t}`),this._options.popup!==false?this.setAttribute("aria-haspopup","dialog"):this.removeAttribute("aria-haspopup");let e=this.querySelector("a[data-cb-crawl]");e||(e=document.createElement("a"),e.setAttribute("data-cb-crawl",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",this.appendChild(e)),e.textContent=`Run on Cowork: ${t}`,e.setAttribute("data-platform","cowork"),e.setAttribute("data-command",t),e.href=`https://claude.ai/cowork?command=${encodeURIComponent(t)}`;}getResolvedTheme(){return this._options.theme||"branded"}render(){if(!this.shadowRoot)return;let t=this.getResolvedTheme(),e=t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":t,a=this._options.variant||"filled",r=l(t),i=this._options.size||"md",d=this._options.shape||"rounded",c=L[i],p=T[d][i];this.setAttribute("data-theme",e),this.setAttribute("data-variant",a);let b=a!=="filled"?"transparent":r.bg,g=a==="ghost"?"transparent":a==="outline"?r.primary:r.border,x=a!=="filled"?r.primary:r.text;this.shadowRoot.innerHTML=` | ||
| <style>${Z}</style> | ||
| <style>${Q}</style> | ||
| <button | ||
@@ -1026,4 +1026,4 @@ class="cb-btn" | ||
| </button> | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:i}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e}})),t===false){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:e}}));});return}A({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:i===true,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};_.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function $(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,_);}$();function X(o){let n=document.createElement("cowork-button");return n.options=o,n}function H(){if(typeof document>"u")return [];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r});}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t});}),o}function q(){let o=H();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return {"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return {"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function Q(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=q();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t);}function yt(){R(),$();} | ||
| export{W as ALT_BRAND_COLOR,s as BRAND_COLOR,w as BRAND_COLOR_ON_DARK,k as CLAUDE_CODE_ICON,C as COWORK_ICON,E as ClaudeCodeButton,B as ClaudePopupDialog,_ as CoworkButton,J as createClaudeCodeButton,X as createCoworkButton,H as discoverButtons,q as generateStructuredData,Q as injectStructuredData,S as isDesktopAppLinkSupported,j as isMobileOrTabletDevice,M as isRestrictedEmbeddedBrowser,yt as register,R as registerClaudeCodeButton,$ as registerCoworkButton,l as resolveTheme,A as showPopup,y as themes};//# sourceMappingURL=index.mjs.map | ||
| `;let u=this.shadowRoot.querySelector(".cb-btn");u.addEventListener("click",()=>this.handleClick()),u.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),this.handleClick());}),this._rendered=true,this.setupSystemThemeWatch();}handleClick(){let{popup:t,command:e,popupTitle:a,popupDescription:r,autoLaunch:i}=this._options;if(this.dispatchEvent(new CustomEvent("cb-open",{bubbles:true,composed:true,detail:{command:e}})),t===false){navigator.clipboard.writeText(e).then(()=>{this._options.onCopy?.(e),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:e}}));});return}A({variant:"cowork",theme:this.getResolvedTheme(),title:a||"Run on Cowork",description:r||"Copy and paste into a Cowork session to get started.",command:e,autoLaunch:i===true,onCopy:d=>{this._options.onCopy?.(d),f("cowork"),this.dispatchEvent(new CustomEvent("cb-copy",{bubbles:true,composed:true,detail:{command:d}}));},onClose:()=>{this.dispatchEvent(new CustomEvent("cb-close",{bubbles:true,composed:true}));}});}setupSystemThemeWatch(){if(this._mqCleanup?.(),this._mqCleanup=null,this.getResolvedTheme()!=="system"||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),e=()=>this.render();t.addEventListener("change",e),this._mqCleanup=()=>t.removeEventListener("change",e);}};_.observedAttributes=["command","theme","size","variant","shape","popup","popup-title","popup-description","auto-launch"];function $(o="cowork-button"){typeof customElements>"u"||customElements.get(o)||customElements.define(o,_);}$();function tt(o){let n=document.createElement("cowork-button");return n.options=o,n}function H(){if(typeof document>"u")return [];let o=[];return document.querySelectorAll("claude-code-button").forEach(n=>{let t=n.getAttribute("command")||"",r=n.getAttribute("prompt-flag")!=="false"?`claude -p "${t}"`:t;o.push({platform:"claude-code",command:t,fullCommand:r});}),document.querySelectorAll("cowork-button").forEach(n=>{let t=n.getAttribute("command")||"";o.push({platform:"cowork",command:t});}),o}function q(){let o=H();return o.length===0?{}:{"@context":"https://schema.org","@type":"WebPage",potentialAction:o.map(t=>{if(t.platform==="claude-code")return {"@type":"Action",name:`Run on Claude Code: ${t.command}`,description:t.command,target:{"@type":"EntryPoint",urlTemplate:`https://claude.ai/code?command=${encodeURIComponent(t.fullCommand||t.command)}`,actionPlatform:"https://claude.ai/code"},object:{"@type":"SoftwareSourceCode",runtimePlatform:"Claude Code",text:t.fullCommand||t.command}};let e={"@type":"EntryPoint",actionPlatform:"https://claude.ai/cowork",urlTemplate:`https://claude.ai/cowork?command=${encodeURIComponent(t.command)}`};return {"@type":"Action",name:`Run on Cowork: ${t.command}`,description:t.command,target:e}})}}function et(){if(typeof document>"u")return;let o=document.querySelector("script[data-claudebuttons-jsonld]");o&&o.remove();let n=q();if(!n||!("potentialAction"in n))return;let t=document.createElement("script");t.type="application/ld+json",t.setAttribute("data-claudebuttons-jsonld",""),t.textContent=JSON.stringify(n,null,2),document.head.appendChild(t);}var j="https://claudebuttons.vercel.app/api/ping",U=false;function ot(){if(U||typeof window>"u"||typeof navigator>"u")return;let o=window.location?.origin;if(!(!o||o==="null"||o.startsWith("file:"))){U=true;try{let n=JSON.stringify({origin:o}),t=new Blob([n],{type:"text/plain"});typeof navigator.sendBeacon=="function"?navigator.sendBeacon(j,t):fetch(j,{method:"POST",body:n,keepalive:!0}).catch(()=>{});}catch{}}}if(typeof window<"u")try{ot();}catch{}function _t(){R(),$();} | ||
| export{G as ALT_BRAND_COLOR,s as BRAND_COLOR,w as BRAND_COLOR_ON_DARK,k as CLAUDE_CODE_ICON,C as COWORK_ICON,E as ClaudeCodeButton,B as ClaudePopupDialog,_ as CoworkButton,X as createClaudeCodeButton,tt as createCoworkButton,H as discoverButtons,q as generateStructuredData,et as injectStructuredData,S as isDesktopAppLinkSupported,V as isMobileOrTabletDevice,M as isRestrictedEmbeddedBrowser,_t as register,R as registerClaudeCodeButton,$ as registerCoworkButton,l as resolveTheme,A as showPopup,y as themes};//# sourceMappingURL=index.mjs.map | ||
| //# sourceMappingURL=index.mjs.map |
+2
-1
| { | ||
| "name": "claudebuttons", | ||
| "version": "1.2.6", | ||
| "version": "1.2.7", | ||
| "description": "Drop-in \"Run on Claude Code\" and \"Run on Cowork\" buttons for any website or framework", | ||
@@ -53,2 +53,3 @@ "main": "./dist/index.js", | ||
| "@types/react": "^19.2.14", | ||
| "@upstash/redis": "^1.37.0", | ||
| "tsup": "^8.4.0", | ||
@@ -55,0 +56,0 @@ "typescript": "^5.7.0" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1062513
0.54%7243
0.07%4
33.33%3
Infinity%