<?php
/*
 * This file is part of the CLIENTXCMS project.
 * It is the property of the CLIENTXCMS association.
 *
 * Personal and non-commercial use of this source code is permitted.
 * However, any use in a project that generates profit (directly or indirectly),
 * or any reuse for commercial purposes, requires prior authorization from CLIENTXCMS.
 *
 * To request permission or for more information, please contact our support:
 * https://clientxcms.com/client/support
 *
 * Learn more about CLIENTXCMS License at:
 * https://clientxcms.com/eula
 *
 * Year: 2025
 */


namespace App\Traits;

trait OseSVGTrait
{
    public function svg()
    {
        $name = strtolower($this->name);
        if (str_contains($name, 'debian')) {
            return $this->debian();
        }
        if (str_contains($name, 'ubuntu')) {
            return $this->ubuntu();
        }
        if (str_contains($name, 'centos')) {
            return $this->centos();
        }
        if (str_contains($name, 'redhat')) {
            return $this->redhat();
        }
        if (str_contains($name, 'windows')) {
            return $this->windows();
        }

        return $this->default();
    }

    private function default(): string
    {
        return '<i class="bi bi-file-earmark-zip" style="font-size: 3rem"></i>';
    }

    private function debian(): string
    {
        return '<svg width="64" height="64" viewBox="-30.5 0 317 317" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" class="os-icon">
                <g id="SVGRepo_bgCarrier" stroke-width="0"/>
                <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
                <g id="SVGRepo_iconCarrier"> <g fill="9CA38F"> <path d="M152.796616,167.425369 C147.545671,167.498421 153.790117,170.131199 160.645273,171.186063 C162.538769,169.7075 164.256942,168.211404 165.788102,166.756218 C161.51897,167.802315 157.173864,167.825692 152.796616,167.425369"> </path> <path d="M180.979901,160.400733 C184.106507,156.084848 186.385715,151.359874 187.189282,146.474187 C186.487987,149.957285 184.597414,152.964086 182.817877,156.137446 C173.002673,162.317606 181.894506,152.467336 182.812034,148.724175 C172.257546,162.007867 181.362691,156.689715 180.979901,160.400733"> </path> <path d="M191.382441,133.330754 C192.016528,123.874962 189.521087,126.864232 188.682455,130.472977 C189.661347,130.981416 190.435693,137.1382 191.382441,133.330754"> </path> <path d="M132.885687,4.08796433 C135.687944,4.59055894 138.940199,4.97627109 138.484357,5.64542322 C141.549601,4.97334903 142.245051,4.35387195 132.885687,4.08796433"> </path> <path d="M138.484357,5.64542322 L136.503199,6.05451186 L138.34702,5.8908764 L138.484357,5.64542322"> </path> <path d="M225.86569,136.916123 C226.178352,145.407634 223.381939,149.527742 220.860199,156.821207 L216.322237,159.088727 C212.608297,166.300376 216.681651,163.667598 214.022575,169.403605 C208.225204,174.558123 196.428841,185.533386 192.653538,186.535654 C189.898033,186.47429 194.520734,183.283399 195.125602,182.032756 C187.364606,187.362597 188.898688,190.033361 177.029273,193.271005 L176.681548,192.499581 C147.408334,206.271258 106.744923,178.979202 107.279661,141.740447 C106.966999,144.104395 106.391354,143.514138 105.742656,144.469653 C104.23195,125.309694 114.590659,106.064996 132.061666,98.207572 C149.149883,89.7482033 169.183538,93.2196126 181.424054,104.627341 C174.700391,95.8202476 161.317348,86.4842604 145.456396,87.3579569 C129.919795,87.60341 115.38546,97.4770565 110.534837,108.195179 C102.575141,113.206515 101.65177,127.512929 98.1832823,130.131096 C93.5167498,164.427334 106.961156,179.245109 129.703562,196.675207 C133.283087,199.08883 130.711673,199.454088 131.196736,201.292065 C123.640283,197.753449 116.720842,192.411919 111.031588,185.872345 C114.050077,190.290502 117.308176,194.585933 121.518867,197.960914 C114.394881,195.547291 104.877725,180.697374 102.098845,180.092507 C114.380271,202.081022 151.925841,218.654956 171.585472,210.432274 C162.489094,210.768311 150.93234,210.619286 140.710969,206.841061 C136.418459,204.631982 130.58018,200.056033 131.623357,199.199869 C158.453727,209.22254 186.169482,206.791385 209.385263,188.180774 C215.290749,183.581449 221.742662,175.756168 223.606937,175.648052 C220.798836,179.87043 224.086155,177.678885 221.929673,181.407435 C227.814706,171.916579 219.37287,177.544469 228.013406,165.017591 L231.204297,169.412371 C230.01794,161.534493 240.987361,151.967664 239.874054,139.507992 C242.38995,135.697623 242.682156,143.607644 240.011391,152.37383 C243.716565,142.649209 240.987361,141.085905 241.939952,133.061924 C242.968518,135.758987 244.318511,138.62553 245.011039,141.471618 C242.597416,132.074267 247.488948,125.645732 248.698681,120.184398 C247.50648,119.655505 244.973052,124.33957 244.394484,113.238657 C244.479224,108.417256 245.73571,110.711074 246.220773,109.524717 C245.274025,108.981213 242.790272,105.284805 241.279566,98.1958837 C242.37534,96.5303086 244.207472,102.514691 245.697724,102.760144 C244.739287,97.1234871 243.088322,92.8251343 243.021115,88.5004829 C238.667243,79.4011828 241.481189,89.7131386 237.948416,84.5936865 C233.314026,70.1382472 241.793849,81.2391597 242.366574,74.6703649 C249.39121,84.8479058 253.397356,100.621195 255.235333,107.154925 C253.832744,99.1893847 251.565224,91.4722197 248.798031,84.0063521 C250.931136,84.903425 245.361686,67.6165079 251.571068,79.0651457 C244.937987,54.6600863 223.183238,31.8563167 203.170038,21.1557267 C205.618726,23.3969481 208.710267,26.2108935 207.599883,26.6521249 C197.647341,20.7261837 199.397655,20.264498 197.97169,17.760291 C189.862969,14.4612834 189.331153,18.0261987 183.960403,17.7661352 C168.678021,9.66033601 165.732583,10.5223442 151.668699,5.44380096 L152.308631,8.43307009 C142.183687,5.06101087 140.512268,9.71293312 129.569147,8.44475834 C128.902917,7.92463135 133.075622,6.56295059 136.509044,6.06327805 C126.720137,7.35482932 127.1789,4.13471732 117.600382,6.41976957 C119.961408,4.76296059 122.456849,3.66718744 124.975666,2.2587537 C116.992593,2.74381594 105.917979,6.90483182 109.336791,3.1207619 C96.3160849,8.92982058 73.1908885,17.0852948 60.2140124,29.2527598 L59.8049238,26.5264762 C53.8585283,33.665073 33.8745482,47.8458384 32.2820246,57.0912417 L30.692423,57.4623435 C27.5979597,62.7016001 25.5963474,68.6392296 23.1418156,74.0304334 C19.0947601,80.926499 17.2100303,76.6836654 17.7856765,77.7648282 C9.82598034,93.903375 5.87243089,107.464663 2.45654075,118.586031 C4.89061816,122.223997 2.51498198,140.486883 3.43543143,155.103036 C-0.561948993,227.289648 54.0981373,297.37822 113.845533,313.560597 C122.602952,316.693048 135.626581,316.573244 146.704117,316.89467 C133.633735,313.157354 131.944783,314.913513 119.213361,310.4749 C110.02932,306.15025 108.01602,301.211965 101.51151,295.566542 L104.085847,300.116191 C91.3281256,295.601606 96.6667323,294.52921 86.2875691,291.241891 L89.0372292,287.650677 C84.9025118,287.338017 78.0853419,280.681559 76.2210666,276.99684 L71.697715,277.175086 C66.2626802,270.468953 63.3669171,265.635863 63.5773055,261.892702 L62.1162747,264.49626 C60.4594657,261.653094 42.1206064,239.346074 51.6348393,244.538578 C49.8669919,242.922678 47.5176543,241.908723 44.9696166,237.280177 L46.9069435,235.065255 C42.3280727,229.174378 38.4797175,221.62377 38.7719237,219.107876 C41.2147672,222.406883 42.909563,223.023438 44.5868265,223.587396 C33.0242283,194.898594 32.3755306,222.006561 23.6181117,194.384311 L25.4706988,194.235286 C24.0505768,192.096336 23.1885686,189.773298 22.0460424,187.494089 L22.8525315,179.45842 C14.5275777,169.833149 20.5236483,138.532024 21.7246156,121.364911 C22.5574032,114.384106 28.6732784,106.953302 33.3252007,95.3001206 L30.4908008,94.8121362 C35.9083032,85.3621887 61.423746,56.8603988 73.2405636,58.3272738 C78.9648825,51.1360799 72.1038815,58.3009752 70.9847319,56.489297 C83.5583634,43.4773562 87.5119129,47.2964908 95.9975802,44.9559193 C105.149478,39.5238067 88.1430783,47.0744141 92.48234,42.8841777 C108.302382,38.8429662 103.69429,33.6972156 124.332812,31.6459283 C126.509749,32.8848825 119.280568,33.5598787 117.465968,35.1670127 C130.647387,28.7180225 159.178398,30.1848974 177.710114,38.7465383 C199.213566,48.7955085 223.373172,78.5011878 224.325764,106.450708 L225.409849,106.742914 C224.860501,117.852593 227.110489,130.700899 223.212459,142.503105 L225.86569,136.916123"> </path> <path d="M95.4832973,174.634096 L94.7469378,178.315894 C98.1978927,183.002881 100.935865,188.081424 105.342334,191.745689 C102.171897,185.556762 99.8167152,182.999958 95.4832973,174.634096"> </path> <path d="M103.641693,174.312669 C101.815405,172.293524 100.734243,169.86237 99.5245086,167.43998 C100.681645,171.697424 103.051437,175.355845 105.257594,179.07563 L103.641693,174.312669"> </path> <path d="M248.00323,142.93557 L247.231806,144.869975 C245.817528,154.916024 242.763974,164.856878 238.082831,174.073061 C243.254879,164.348438 246.600641,153.712134 248.00323,142.93557"> </path> <path d="M133.923019,1.56914713 C137.473324,0.268829677 142.651217,0.856164081 146.417755,0 C141.508691,0.412010701 136.623004,0.657463884 131.79868,1.27986303 L133.923019,1.56914713"> </path> <path d="M9.2824769,67.8473509 C10.1006542,75.4213348 3.58445657,78.3609288 10.7259754,73.3671253 C14.5538762,64.7441213 9.22987977,70.9856451 9.2824769,67.8473509"> </path> <path d="M0.890315672,102.900403 C2.53543641,97.8510804 2.83348671,94.8179803 3.46172998,91.8959186 C-1.08499804,97.7078994 1.3695338,98.9468536 0.890315672,102.900403"> </path> </g> </g>
                </svg>';
    }

    private function ubuntu(): string
    {
        return '<svg width="64" height="64" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" class="os-icon">
                <path d="M16.469 9.375c-1.063-0.594-1.406-1.938-0.813-3 0.406-0.719 1.156-1.094 1.906-1.094 0.375 0 0.75 0.094 1.094 0.281 1.063 0.625 1.406 1.969 0.813 3-0.406 0.719-1.156 1.094-1.906 1.094-0.375 0-0.75-0.094-1.094-0.281zM21.938 15.594h-3.625c-0.125-1.688-0.969-3.188-2.25-4.156-0.219-0.156-0.438-0.313-0.688-0.469-0.813-0.438-1.75-0.688-2.75-0.688-1.031 0-1.969 0.25-2.813 0.719l-2-3.031c1.406-0.844 3.031-1.313 4.813-1.313 0.688 0 1.375 0.063 2.063 0.219-0.25 1.219 0.281 2.5 1.406 3.156 0.438 0.25 0.938 0.375 1.469 0.375 0.719 0 1.406-0.25 1.938-0.719 1.438 1.563 2.344 3.625 2.438 5.906zM7.125 8.438l2 3.031c-1.25 0.969-2.094 2.438-2.188 4.125-0.031 0.125-0.031 0.25-0.031 0.406 0 0.125 0 0.281 0.031 0.406 0.125 1.781 1.063 3.313 2.438 4.281l-1.906 3.094c-1.813-1.188-3.188-3-3.813-5.125 0.875-0.5 1.5-1.469 1.5-2.563s-0.625-2.094-1.563-2.594c0.594-2.063 1.844-3.844 3.531-5.063zM2.188 13.906c1.219 0 2.219 0.969 2.219 2.188s-1 2.219-2.219 2.219-2.188-1-2.188-2.219 0.969-2.188 2.188-2.188zM8.188 24.219l1.906-3.125c0.75 0.375 1.625 0.594 2.531 0.594 1 0 1.938-0.25 2.781-0.719 0.25-0.125 0.469-0.281 0.688-0.469 1.25-0.938 2.094-2.406 2.219-4.094h3.625c-0.094 2.375-1.094 4.531-2.656 6.125-0.469-0.344-1.063-0.531-1.656-0.531-0.531 0-1.031 0.125-1.469 0.375-1 0.594-1.531 1.656-1.469 2.719-0.688 0.156-1.375 0.25-2.063 0.25-1.625 0-3.125-0.406-4.438-1.125zM17.625 22.75c0.75 0 1.5 0.375 1.906 1.094 0.594 1.063 0.219 2.438-0.813 3.031-0.344 0.188-0.719 0.281-1.094 0.281-0.781 0-1.5-0.375-1.906-1.094-0.625-1.063-0.25-2.406 0.813-3.031 0.344-0.188 0.719-0.281 1.094-0.281z"></path>
                </svg>';
    }

    private function centos(): string
    {
        return '<svg width="64" height="64" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" class="os-icon">
                <path d="M17.722 19.556l4.439 4.372-2.316 2.281h-2.124zM14.423 19.435v6.773h-2.248l-2.314-2.278zM16.010 17.872l1.052 1.036v7.96h2.113l-3.164 3.118-3.165-3.118h2.237v-8.081zM19.546 17.633h6.694v2.247l-2.231 2.244zM17.722 17.633h0.893l5.395 5.427 0.232-0.234 1.998-2.012v5.393h-5.456l2.316-2.281-5.378-5.297zM13.538 17.633h0.885v0.875l-5.503 5.421 2.314 2.279h-5.386v-5.426l2.247 2.212zM5.848 17.633h6.751l-4.502 4.436-2.247-2.214zM15.083 14.126l1.012 1.018 0.232-0.235 0.767-0.772v0.857h0.96l-1.031 1.037 0.937 0.942h-0.898v1.010l-1.052-1.037-0.926 0.912v-0.884h-0.875l0.976-0.962-0.235-0.232-0.852-0.84h0.985zM26.957 12.903l3.109 3.128-3.165 3.187v-2.244h-8.010l-0.937-0.942 1.031-1.037h7.973zM5.188 12.818v2.121h7.969l1.088 1.072-0.977 0.962h-8.078v2.232l-3.245-3.193zM8.096 9.954l4.393 4.326h-6.641v-2.112zM24.010 9.938l2.287 2.303v2.094h-6.657zM20.794 5.814h5.503v5.491l-2.287-2.302-5.3 5.332h-0.955v-0.862l5.325-5.357zM17.756 5.814h2.108l2.287 2.302-4.395 4.422zM12.38 5.76h2.043v6.767l-4.385-4.411zM5.848 5.76h5.602l-2.342 2.357 5.315 5.347v0.817h-0.997l-5.331-5.251-2.247 2.212zM16.095 2.023l3.112 3.132h-2.112v8.049l-1 1.006-1.012-1.018v-8.088h-2.048zM16.095 1.087l-3.99 4.016h-6.917v6.791l-4.184 4.119 4.185 4.121v6.736h6.716l4.105 4.044 4.105-4.044h6.786v-6.716l4.095-4.121-4.039-4.064v-6.814h-6.821z"></path>
                </svg>';
    }

    private function redhat(): string
    {
        return '<svg width="64" height="64" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" class="os-icon">
        <path d="M26.135 15.933c0.136 0.467 0.233 1.011 0.271 1.572l0.001 0.024c0 2.206-2.479 3.43-5.74 3.43-7.367 0.005-13.821-4.313-13.821-7.165 0-0.002 0-0.004 0-0.005 0-0.416 0.087-0.811 0.245-1.169l-0.007 0.019c-2.648 0.132-6.080 0.606-6.080 3.634 0 4.96 11.753 11.073 21.058 11.073 7.135 0 8.934-3.227 8.934-5.773 0-2.006-1.733-4.28-4.857-5.638zM21.010 17.732c1.971 0 4.824-0.407 4.824-2.752 0.001-0.020 0.001-0.043 0.001-0.067 0-0.167-0.019-0.33-0.054-0.486l0.003 0.015-1.175-5.099c-0.27-1.122-0.507-1.631-2.477-2.615-1.684-0.889-3.637-1.604-5.692-2.045l-0.151-0.027c-0.916 0-1.183 1.182-2.277 1.182-1.052 0-1.833-0.882-2.818-0.882-0.946 0-1.562 0.644-2.037 1.969 0 0-1.325 3.736-1.496 4.279-0.023 0.080-0.036 0.172-0.036 0.267 0 0.014 0 0.028 0.001 0.042l-0-0.002c0 1.452 5.72 6.216 13.384 6.216z"></path>
        </svg>';
    }

    private function windows(): string
    {
        return '<svg width="64" height="64" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="currentColor" class="os-icon">
                <g id="Page-1" stroke="none" stroke-width="1" fill="currentColor" fill-rule="evenodd">
                <g id="Dribbble-Light-Preview" transform="translate(-60.000000, -7439.000000)" fill="currentColor">
                    <g id="icons" transform="translate(56.000000, 160.000000)">
                        <path d="M13.1458647,7289.43426 C13.1508772,7291.43316 13.1568922,7294.82929 13.1619048,7297.46884 C16.7759398,7297.95757 20.3899749,7298.4613 23.997995,7299 C23.997995,7295.84873 24.002005,7292.71146 23.997995,7289.71311 C20.3809524,7289.71311 16.7649123,7289.43426 13.1458647,7289.43426 M4,7289.43526 L4,7296.22153 C6.72581454,7296.58933 9.45162907,7296.94113 12.1724311,7297.34291 C12.1774436,7294.71736 12.1704261,7292.0908 12.1704261,7289.46524 C9.44661654,7289.47024 6.72380952,7289.42627 4,7289.43526 M4,7281.84344 L4,7288.61071 C6.72581454,7288.61771 9.45162907,7288.57673 12.1774436,7288.57973 C12.1754386,7285.96017 12.1754386,7283.34361 12.1724311,7280.72405 C9.44461153,7281.06486 6.71679198,7281.42567 4,7281.84344 M24,7288.47179 C20.3879699,7288.48578 16.7759398,7288.54075 13.1619048,7288.55175 C13.1598997,7285.88921 13.1598997,7283.22967 13.1619048,7280.56914 C16.7689223,7280.01844 20.3839599,7279.50072 23.997995,7279 C24,7282.15826 23.997995,7285.31353 24,7288.47179" id="windows-[#174]"></path>
                    </g>
                </g>
            </g>
            </svg>';
    }
}
