import{__awaiter,__generator}from"tslib";import{r as registerInstance,c as createEvent,h,H as Host}from"./index-4a3a9179.js";var pdsCopytextCss=":host(.pds-copytext){--background:var(--pine-color-base-white);--background-hover:var(--pine-color-neutral-grey-200);--border:var(--pine-border-interactive);--border-hover:var(--pine-border-interactive-hover-color);--border-radius:var(--pine-border-radius-md);--box-shadow-focus:0 0 0 4px var(--pine-color-primary-200);--color-hover:var(--pine-color-neutral-charcoal-400);--font-size:var(--pine-font-size-body);--font-weight:var(--pine-font-weight-semibold);--line-height:var(--pine-line-height-md);--spacing-sm:var(--pine-spacing-sm);--spacing-xs:var(--pine-spacing-xs);--spacing-xxs:var(--pine-spacing-xxs)}:host(.pds-copytext) pds-button{-ms-flex-align:center;align-items:center;background:var(--background);border:0;border-radius:var(--border-radius);display:-ms-inline-flexbox;display:inline-flex;font-size:var(--font-size);font-weight:var(--font-weight);max-width:100%;padding:var(--spacing-xxs) var(--spacing-xs)}:host(.pds-copytext) pds-button:hover{background-color:var(--background-hover);color:var(--color-hover)}:host(.pds-copytext) pds-button:focus-visible{-webkit-box-shadow:var(--box-shadow-focus);box-shadow:var(--box-shadow-focus);outline:none}:host(.pds-copytext) pds-button span{line-height:var(--line-height);-webkit-margin-end:var(--spacing-xs);margin-inline-end:var(--spacing-xs);white-space:nowrap}:host(.pds-copytext) pds-button :nth-child(2){-ms-flex-negative:0;flex-shrink:0}:host(.pds-copytext):host(.pds-copytext--bordered){border:0;padding:0}:host(.pds-copytext):host(.pds-copytext--bordered) pds-button{padding:0}:host(.pds-copytext):host(.pds-copytext--bordered) pds-button:hover{background:none}:host(.pds-copytext):host(.pds-copytext--bordered) span{border:var(--border);border-radius:var(--border-radius);-webkit-margin-end:var(--spacing-sm);margin-inline-end:var(--spacing-sm);padding-block:var(--spacing-xs);padding-inline:var(--spacing-sm)}:host(.pds-copytext):host(.pds-copytext--bordered) :hover span{border-color:var(--border-hover)}:host(.pds-copytext):host(.pds-copytext--full-width){display:-ms-flexbox;display:flex;width:100%}:host(.pds-copytext):host(.pds-copytext--full-width) pds-button{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;width:100%}:host(.pds-copytext):host(.pds-copytext--full-width) pds-button span{text-align:left;width:100%}:host(.pds-copytext):host(.pds-copytext--truncated) pds-button{display:-ms-flexbox;display:flex;width:100%}:host(.pds-copytext):host(.pds-copytext--truncated) pds-button span{overflow:hidden;text-align:left;text-overflow:ellipsis;width:100%}";var PdsCopytextStyle0=pdsCopytextCss;var PdsCopytext=function(){function t(t){var e=this;registerInstance(this,t);this.pdsCopyTextClick=createEvent(this,"pdsCopyTextClick",7);this.copyToClipboard=function(t){return __awaiter(e,void 0,void 0,(function(){var e,o;return __generator(this,(function(s){switch(s.label){case 0:s.trys.push([0,4,,5]);if(!navigator.clipboard)return[3,2];return[4,navigator.clipboard.writeText(t)];case 1:s.sent();this.pdsCopyTextClick.emit("Copied to clipboard");return[3,3];case 2:e=document.createElement("textarea");e.value=t;e.setAttribute("readonly","");e.style.position="absolute";e.style.left="-9999px";document.body.appendChild(e);e.focus();e.setSelectionRange(0,e.value.length);document.execCommand("copy");document.body.removeChild(e);this.pdsCopyTextClick.emit("Copied to clipboard");s.label=3;case 3:return[3,5];case 4:o=s.sent();this.pdsCopyTextClick.emit("Error writing text to clipboard: ".concat(o));return[3,5];case 5:return[2]}}))}))};this.handleClick=function(){e.copyToClipboard(e.value)};this.border=true;this.componentId=undefined;this.fullWidth=false;this.truncate=false;this.value=undefined}t.prototype.classNames=function(){var t=["pds-copytext"];if(this.border){t.push("pds-copytext--bordered")}if(this.fullWidth){t.push("pds-copytext--full-width")}if(this.truncate){t.push("pds-copytext--truncated")}return t.join("  ")};t.prototype.render=function(){return h(Host,{key:"4acd4381ec825bb968a28882592e94e63f03b455",class:this.classNames(),id:this.componentId},h("pds-button",{key:"0827df991bc213211d021daac15adbea51c04b2d",type:"button",variant:"unstyled",onClick:this.handleClick},h("span",{key:"9ccdf4d2087ce38db135ac2147b2376eb3bb114e"},this.value),h("pds-icon",{key:"6e68ea1f67195d6ace3a4c1499d47ad1fe8e9dea",name:"copy",size:"16px"})))};return t}();PdsCopytext.style=PdsCopytextStyle0;export{PdsCopytext as pds_copytext};
//# sourceMappingURL=pds-copytext.entry.js.map