{
  "schemaVersion": 1,
  "kind": "kittycord-studio",
  "language": "javascript",
  "metadata": {
    "id": "local.link-lens",
    "name": "Link Lens",
    "version": "1.0.0",
    "author": "Kittencord contributors"
  },
  "source": "globalThis.kittycordPlugin = /** @type {KittyPlugin} */ ({\n    start(api) {\n        let result = \"Paste a public HTTP(S) link in settings. Nothing is opened or fetched.\";\n        const show = () => api.publishPanel({title:\"Link Lens\",text:result,actions:[{id:\"inspect\",label:\"Inspect link\"},{id:\"clean\",label:\"Remove trackers\"}],settings:[{id:\"url\",label:\"Public link (no secrets)\",type:\"text\",default:\"\"},{id:\"fragment\",label:\"Remove fragment when cleaning\",type:\"boolean\",default:false}]});\n        api.onAction(id => {\n            try {\n                const url = new URL(String(api.settings.url ?? \"\"));\n                if (!['https:', 'http:'].includes(url.protocol)) throw new Error(\"Only HTTP and HTTPS links are supported.\");\n                if (url.username || url.password) throw new Error(\"This link contains credentials. Remove them before using this tool.\");\n                const warnings = [];\n                if (url.protocol === \"http:\") warnings.push(\"Unencrypted HTTP\");\n                if (url.hostname.split('.').some(part => part.startsWith('xn--'))) warnings.push(\"International domain in punycode: verify the spelling\");\n                if (/^[0-9.]+$/.test(url.hostname) || url.hostname.startsWith('[')) warnings.push(\"IP address instead of a domain\");\n                let removed = 0;\n                if (id === \"clean\") for (const key of Array.from(url.searchParams.keys())) {\n                    if (/^(utm_.+|fbclid|gclid|dclid|msclkid|mc_cid|mc_eid|igshid)$/i.test(key)) { removed += url.searchParams.getAll(key).length; url.searchParams.delete(key); }\n                }\n                if (id === \"clean\" && api.settings.fragment === true) url.hash = \"\";\n                result = \"Host: \" + url.hostname + \"\\n\" + (warnings.join(\". \") || \"No listed URL warning detected\") + \". This is not a safety verdict.\\n\" + (id === \"clean\" ? \"Tracking values removed: \" + removed + \". Check the destination before sharing.\\n\" : \"\") + url.href;\n                if (result.length > 2000) throw new Error(\"Result is too long. Use a shorter link.\");\n            } catch (error) { result = error instanceof Error ? error.message : \"Invalid link.\"; }\n            show();\n        }); show();\n    }\n});",
  "tokens": [],
  "tests": [],
  "api": "utility-v1"
}