UNPKG

@kit-data-manager/pid-component

Version:

The PID-Component is a web component that can be used to evaluate and display FAIR Digital Objects, PIDs, ORCiDs, and possibly other identifiers in a user-friendly way. It is easily extensible to support other identifier types.

19 lines 25.6 kB
/*! * * Copyright 2024 Karlsruhe Institute of Technology. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import{r as t,h as e}from"./p-DzUQJMIf.js";const o='/*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial}}}@layer theme{:host,:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-500:oklch(63.7% .237 25.331);--color-green-100:oklch(96.2% .044 156.743);--color-green-400:oklch(79.2% .209 151.711);--color-green-600:oklch(62.7% .194 149.214);--color-green-800:oklch(44.8% .119 151.328);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-purple-400:oklch(71.4% .203 305.504);--color-purple-600:oklch(55.8% .288 302.321);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-gray-800:oklch(27.8% .033 256.848);--color-gray-900:oklch(21% .034 264.665);--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:1.33333;--text-sm:.875rem;--text-sm--line-height:1.42857;--font-weight-medium:500;--radius-md:.375rem;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,::backdrop,:after,:before{border:0 solid;box-sizing:border-box;margin:0;padding:0}::file-selector-button{appearance:button;background-color:#0000;border:0 solid;border-radius:0;box-sizing:border-box;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;margin:0;margin-inline-end:4px;opacity:1;padding:0}:host,html{-webkit-text-size-adjust:100%;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);tab-size:4;-webkit-tap-highlight-color:transparent;line-height:1.5}hr{border-top-width:1px;color:inherit;height:0}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-size:1em;font-variation-settings:var(--default-mono-font-variation-settings,normal)}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{border-collapse:collapse;border-color:inherit;text-indent:0}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}menu,ol,ul{list-style:none}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{height:auto;max-width:100%}button,input,optgroup,select,textarea{background-color:#0000;border-radius:0;color:inherit;font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;opacity:1}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:currentColor;color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex;padding-block:0}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit-month-field,::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-day-field,::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field,::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-meridiem-field,::-webkit-datetime-edit-millisecond-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.collapse{visibility:collapse}.sr-only{clip:rect(0,0,0,0);border-width:0;height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}.absolute,.sr-only{position:absolute}.fixed{position:fixed}.relative{position:relative}.top-2{top:calc(var(--spacing)*2)}.right-2{right:calc(var(--spacing)*2)}.z-10{z-index:10}.container{width:100%}.mr-2{margin-right:calc(var(--spacing)*2)}.mb-1{margin-bottom:calc(var(--spacing)*1)}.ml-2{margin-left:calc(var(--spacing)*2)}.ml-4{margin-left:calc(var(--spacing)*4)}.flex{display:flex}.table{display:table}.h-4{height:calc(var(--spacing)*4)}.min-h-5{min-height:calc(var(--spacing)*5)}.w-4{width:calc(var(--spacing)*4)}.w-full{width:100%}.flex-grow{flex-grow:1}.cursor-pointer{cursor:pointer}.list-none{list-style-type:none}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.rounded{border-radius:.25rem}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-600{border-color:var(--color-gray-600)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-700{background-color:var(--color-gray-700)}.bg-gray-800{background-color:var(--color-gray-800)}.bg-gray-900{background-color:var(--color-gray-900)}.bg-green-100{background-color:var(--color-green-100)}.bg-green-600{background-color:var(--color-green-600)}.bg-white{background-color:var(--color-white)}.p-1{padding:calc(var(--spacing)*1)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.px-2{padding-inline:calc(var(--spacing)*2)}.px-3{padding-inline:calc(var(--spacing)*3)}.py-1{padding-block:calc(var(--spacing)*1)}.py-1\\.5{padding-block:calc(var(--spacing)*1.5)}.py-4{padding-block:calc(var(--spacing)*4)}.pr-12{padding-right:calc(var(--spacing)*12)}.pl-3{padding-left:calc(var(--spacing)*3)}.pl-5{padding-left:calc(var(--spacing)*5)}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.whitespace-pre-wrap{white-space:pre-wrap}.text-blue-400{color:var(--color-blue-400)}.text-blue-500{color:var(--color-blue-500)}.text-blue-600{color:var(--color-blue-600)}.text-gray-50{color:var(--color-gray-50)}.text-gray-200{color:var(--color-gray-200)}.text-gray-300{color:var(--color-gray-300)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-800{color:var(--color-gray-800)}.text-green-400{color:var(--color-green-400)}.text-green-600{color:var(--color-green-600)}.text-green-800{color:var(--color-green-800)}.text-purple-400{color:var(--color-purple-400)}.text-purple-600{color:var(--color-purple-600)}.text-red-500{color:var(--color-red-500)}.text-white{color:var(--color-white)}.opacity-0{opacity:0}.opacity-75{opacity:.75}.shadow{--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a),0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.transition-all,.transition-opacity{transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function))}.duration-200{--tw-duration:.2s;transition-duration:.2s}.select-none{-webkit-user-select:none;user-select:none}.focus\\:ring-2:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(2px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\\:ring-blue-500:focus{--tw-ring-color:var(--color-blue-500)}.focus\\:ring-offset-1:focus{--tw-ring-offset-width:1px;--tw-ring-offset-shadow:var(--tw-ring-inset,)0 0 0 var(--tw-ring-offset-width)var(--tw-ring-offset-color)}.focus\\:outline-none:focus{--tw-outline-style:none;outline-style:none}} /*! tailwindcss v4.1.8 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,::backdrop,:after,:before{--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial}}}@layer base{}@layer components;@layer utilities{.absolute,.sr-only{position:absolute}}:host{--color-text-secondary:#6b7280;display:block;font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Open Sans,Helvetica Neue,sans-serif}:host([theme=dark]){--color-text-secondary:#9ca3af;--color-background:#1f2937;--color-text:#f9fafb}:host([theme=light]){--color-text-secondary:#6b7280;--color-background:#fff;--color-text:#111827}summary:before{color:var(--color-text-secondary);content:"►";font-size:.75rem;left:0;position:absolute;transform:rotate(0);transition:transform .2s}details[open]>summary:before{transform:rotate(90deg)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}@media (hover:hover){.group-hover\\:opacity-100:is(:where(.group):hover *){opacity:1}.hover\\:border-blue-400:hover{border-color:var(--color-blue-400)}.hover\\:border-blue-600:hover{border-color:var(--color-blue-600)}.hover\\:bg-gray-50:hover{background-color:var(--color-gray-50)}.hover\\:bg-gray-200:hover{background-color:var(--color-gray-200)}.hover\\:bg-gray-600:hover{background-color:var(--color-gray-600)}.hover\\:bg-gray-700:hover{background-color:var(--color-gray-700)}.hover\\:text-gray-800:hover{color:var(--color-gray-800)}.hover\\:text-white:hover{color:var(--color-white)}.hover\\:opacity-100:hover{opacity:1}}';const r=class{constructor(o){t(this,o);this.viewMode="tree";this.maxHeight=500;this.showLineNumbers=true;this.expandAll=false;this.theme="system";this.expandedNodes=new Set;this.parsedData=null;this.error=null;this.copied=false;this.isDarkMode=false;this.sanitizeData=t=>{if(Array.isArray(t)){return t.map(this.sanitizeData)}if(t!==null&&typeof t==="object"){const e={};Object.entries(t).forEach((([t,o])=>{if(!t.startsWith("$")){e[t]=this.sanitizeData(o)}}));return e}return t};this.toggleView=()=>{this.currentViewMode=this.currentViewMode==="tree"?"code":"tree"};this.copyToClipboard=async()=>{try{const t=JSON.stringify(this.parsedData,null,2);await navigator.clipboard.writeText(t);this.copied=true;setTimeout((()=>{this.copied=false}),2e3)}catch(t){console.error("Failed to copy JSON to clipboard:",t);this.createFallbackCopyMethod(JSON.stringify(this.parsedData,null,2))}};this.handleDarkModeChange=()=>{this.updateDarkMode()};this.renderTreeNode=(t,o,r=0,i="")=>{const a=typeof o==="object"&&o!==null;const n=i?`${i}.${t}`:t;const s=`node-${n}`;const l=Array.isArray(o);const c=t=>{if(t.key==="Enter"||t.key===" "){t.preventDefault();const e=t.target.closest("details");if(e){e.open=!e.open;if(e.open){this.expandedNodes.add(s)}else{this.expandedNodes.delete(s)}this.expandedNodes=new Set(this.expandedNodes)}}};if(a){const i=l?Object.entries(o):Object.entries(o);const a=i.length;const d=`${a} ${a===1?"item":"items"}`;const h=l?"array":"object";const g=this.expandedNodes.has(s);const p=t=>{const e=t.target.closest("details");if(e&&e.open){this.expandedNodes.add(s)}else{this.expandedNodes.delete(s)}this.expandedNodes=new Set(this.expandedNodes)};return e("div",{class:"ml-4"},e("details",{class:"mb-1",open:g,onToggle:p,id:s},e("summary",{class:`group relative flex cursor-pointer list-none items-center rounded py-1 pl-5 font-mono ${this.isDarkMode?"hover:bg-gray-700":"hover:bg-gray-50"} focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 focus:outline-none`,onKeyDown:c,tabIndex:0,role:"button","aria-expanded":g?"true":"false","aria-controls":`${s}-content`,"aria-label":`${t}: ${h} with ${d}, ${g?"click to collapse":"click to expand"}`},e("div",{class:"flex w-full items-center"},e("span",{class:`mr-2 font-medium ${this.isDarkMode?"text-blue-400":"text-blue-600"}`},t,": "),e("span",{class:`flex items-center gap-1 ${this.isDarkMode?"text-gray-400":"text-gray-500"}`},e("span",null,l?"[":"{"),e("span",null,d),e("span",null,l?"]":"}"),e("span",{class:`ml-2 text-xs opacity-0 transition-opacity duration-200 group-hover:opacity-100 ${this.isDarkMode?"text-blue-400":"text-blue-500"}`,"aria-hidden":"true"},g?"Click to collapse":"Click to expand")))),e("div",{id:`${s}-content`,class:`ml-4 border-l-2 pl-3 ${this.isDarkMode?"border-gray-600":"border-gray-200"}`,role:"group","aria-label":`Contents of ${t} ${h}`},i.map((([t,o],i)=>e("div",{key:`${s}-${i}`},this.renderTreeNode(l?`${t}`:t,o,r+1,n)))))))}let d="";let h=JSON.stringify(o);let g=typeof o;if(g==="string"){d=this.isDarkMode?"text-green-400":"text-green-600"}else if(g==="number"){d=this.isDarkMode?"text-blue-400":"text-blue-600"}else if(g==="boolean"){d=this.isDarkMode?"text-purple-400":"text-purple-600"}else if(o===null){d=this.isDarkMode?"text-gray-400":"text-gray-500";h="null";g="undefined"}return e("div",{class:`flex items-center py-1 font-mono text-sm ${this.isDarkMode?"hover:bg-gray-700":"hover:bg-gray-50"} rounded`,tabIndex:0,role:"treeitem","aria-label":`${t}: ${h} (${g})`},e("span",{class:`font-medium ${this.isDarkMode?"text-blue-400":"text-blue-600"}`},t,": "),e("span",{class:d},h))};this.formatCodeLine=t=>{const e=this.isDarkMode?"text-green-400":"text-green-600";const o=this.isDarkMode?"text-purple-400":"text-purple-600";const r=this.isDarkMode?"text-gray-400":"text-gray-500";const i=this.isDarkMode?"text-blue-400":"text-blue-600";return t.replace(/(".+?")(: )?/g,`<span class="${e}">$1</span>$2`).replace(/: (true|false)([,}\]\s])/g,`: <span class="${o}">$1</span>$2`).replace(/: (null)([,}\]\s])/g,`: <span class="${r}">$1</span>$2`).replace(/: ([0-9]+(\.[0-9]+)?)([,}\]\s])/g,`: <span class="${i}">$1</span>$3`)}}handleDataChange(){this.parseData()}handleViewModeChange(){this.currentViewMode=this.viewMode}handleExpandAllChange(){if(this.expandAll){this.expandAllNodes()}else{this.collapseAllNodes()}}handleThemeChange(){this.updateDarkMode()}componentWillLoad(){this.currentViewMode=this.viewMode;this.parseData();if(this.expandAll){this.expandAllNodes()}this.initializeDarkMode()}parseData(){try{let t;if(typeof this.data==="string"){t=JSON.parse(this.data)}else if(this.data!==null&&typeof this.data==="object"){t=this.data}else{throw new Error("Invalid data format")}this.parsedData=this.sanitizeData(t);this.error=null}catch(t){this.error=t.message;this.parsedData=null}}createFallbackCopyMethod(t){const e=document.createElement("textarea");e.style.position="fixed";e.style.left="-999999px";e.style.top="-999999px";e.style.opacity="0";e.style.pointerEvents="none";e.value=t;document.body.appendChild(e);e.focus();e.select();try{const t=document.execCommand("copy");if(t){this.copied=true;setTimeout((()=>{this.copied=false}),2e3)}}catch(t){console.error("Fallback copy failed:",t)}finally{document.body.removeChild(e)}}disconnectedCallback(){this.cleanupDarkModeListener()}cleanupDarkModeListener(){if(this.darkModeMediaQuery){if(this.darkModeMediaQuery.removeEventListener){this.darkModeMediaQuery.removeEventListener("change",this.handleDarkModeChange)}else if(this.darkModeMediaQuery.removeListener){this.darkModeMediaQuery.removeListener(this.handleDarkModeChange)}}}async expandAllNodes(){this.expandNodeRecursive(this.parsedData,"root")}async collapseAllNodes(){this.expandedNodes=new Set}expandNodeRecursive(t,e){if(t!==null&&typeof t==="object"){this.expandedNodes.add(e);Object.entries(t).forEach((([t,o])=>{const r=e?`${e}.${t}`:t;this.expandNodeRecursive(o,r)}));this.expandedNodes=new Set(this.expandedNodes)}}initializeDarkMode(){if(window.matchMedia){this.darkModeMediaQuery=window.matchMedia("(prefers-color-scheme: dark)");this.updateDarkMode();if(this.darkModeMediaQuery.addEventListener){this.darkModeMediaQuery.addEventListener("change",this.handleDarkModeChange)}else if(this.darkModeMediaQuery.addListener){this.darkModeMediaQuery.addListener(this.handleDarkModeChange)}}else{this.isDarkMode=this.theme==="dark"}}updateDarkMode(){if(this.theme==="dark"){this.isDarkMode=true}else if(this.theme==="light"){this.isDarkMode=false}else if(this.theme==="system"&&this.darkModeMediaQuery){this.isDarkMode=this.darkModeMediaQuery.matches}}render(){if(this.error){return e("div",{class:"p-4 text-center text-red-500",role:"alert","aria-live":"assertive"},e("p",null,"Invalid JSON: ",this.error),e("slot",null))}if(!this.parsedData){return e("div",{class:"p-4 text-center text-gray-500",role:"status","aria-live":"polite"},e("p",null,"No data provided"),e("slot",null))}const t=JSON.stringify(this.parsedData,null,2);const o=this.maxHeight>0?{maxHeight:`${this.maxHeight}px`}:{};const r=`json-viewer-${Math.random().toString(36).substring(2,11)}`;const i=`${r}-content`;return e("div",{class:`overflow-hidden rounded-lg border shadow ${this.isDarkMode?"border-gray-600 bg-gray-800 text-gray-50":"border-gray-200 bg-white text-gray-800"}`,role:"region","aria-labelledby":`${r}-title`},e("div",{class:`flex items-center justify-between border-b p-3 ${this.isDarkMode?"border-gray-600":"border-gray-200"}`},e("div",{class:"flex items-center gap-2"},e("span",{id:`${r}-title`,class:`text-sm font-medium ${this.isDarkMode?"text-gray-200":"text-gray-800"}`},"JSON Viewer"),e("span",{class:`text-xs ${this.isDarkMode?"text-gray-400":"text-gray-500"}`,"aria-live":"polite"},"(",Object.keys(this.parsedData).length," ",Object.keys(this.parsedData).length===1?"property":"properties",")")),e("button",{onClick:this.toggleView,class:`flex cursor-pointer items-center gap-1 rounded-md px-3 py-1.5 text-xs font-medium transition-all duration-200 ${this.isDarkMode?"border border-gray-600 bg-gray-900 text-gray-50 hover:border-blue-600 hover:bg-gray-700":"border border-gray-200 bg-gray-100 text-gray-800 hover:border-blue-400 hover:bg-gray-50"} focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 focus:outline-none`,"aria-controls":i,"aria-label":`Switch to ${this.currentViewMode==="tree"?"code":"tree"} view`,type:"button"},this.currentViewMode==="tree"?"Code View":"Tree View")),e("div",{id:i,class:`relative overflow-auto ${this.isDarkMode?"bg-gray-800":"bg-white"}`,style:o,role:"group","aria-label":`JSON data in ${this.currentViewMode} view`},e("button",{onClick:this.copyToClipboard,class:`absolute top-2 right-2 z-10 rounded-md p-1 transition-all duration-200 ${this.copied?this.isDarkMode?"bg-green-600 text-white":"bg-green-100 text-green-800":this.isDarkMode?"bg-gray-700 text-gray-300 hover:bg-gray-600 hover:text-white":"bg-gray-100 text-gray-600 hover:bg-gray-200 hover:text-gray-800"} opacity-75 hover:opacity-100 focus:ring-2 focus:ring-blue-500 focus:ring-offset-1 focus:outline-none`,title:this.copied?"Copied!":"Copy JSON to clipboard","aria-label":this.copied?"JSON copied to clipboard":"Copy JSON to clipboard",type:"button"},e("span",{class:"sr-only"},this.copied?"Copied!":"Copy JSON"),this.copied?e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-4 w-4","aria-hidden":"true"},e("title",null,"Check mark"),e("polyline",{points:"20 6 9 17 4 12"})):e("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-4 w-4","aria-hidden":"true"},e("title",null,"Copy icon"),e("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"}))),this.currentViewMode==="tree"&&e("div",{class:`p-4 pr-12 ${this.isDarkMode?"":"bg-gray-50"}`},Object.entries(this.parsedData).map((([t,o],r)=>e("div",{key:`root-${r}`},this.renderTreeNode(t,o,0,"root"))))),this.currentViewMode==="code"&&e("div",{class:`pr-12 font-mono text-sm ${this.isDarkMode?"":"bg-gray-50"}`},this.showLineNumbers?e("div",{class:"flex"},e("div",{class:`border-r px-2 py-4 text-right select-none ${this.isDarkMode?"border-gray-600 bg-gray-900 text-gray-400":"border-gray-200 bg-gray-100 text-gray-500"}`},t.split("\n").map(((t,o)=>e("div",{class:"min-h-5",key:`line-${o}`},o+1)))),e("pre",{class:`flex-grow overflow-x-auto p-4 whitespace-pre-wrap ${this.isDarkMode?"text-gray-200":"text-gray-800"}`},t.split("\n").map(((t,o)=>e("div",{class:"min-h-5",key:`code-${o}`,innerHTML:this.formatCodeLine(t)}))))):e("pre",{class:"flex-grow overflow-x-auto p-4 whitespace-pre-wrap"},t.split("\n").map(((t,o)=>e("div",{class:"min-h-5",key:`code-${o}`,innerHTML:this.formatCodeLine(t)})))))))}static get watchers(){return{data:["handleDataChange"],viewMode:["handleViewModeChange"],expandAll:["handleExpandAllChange"],theme:["handleThemeChange"]}}};r.style=o;export{r as json_viewer}; //# sourceMappingURL=p-5625ce20.entry.js.map